@jupyter-notebook/application 7.0.0-beta.4 → 7.0.0-rc.0

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/lib/shell.d.ts CHANGED
@@ -14,6 +14,37 @@ export declare const INotebookShell: Token<INotebookShell>;
14
14
  */
15
15
  export interface INotebookShell extends NotebookShell {
16
16
  }
17
+ /**
18
+ * The namespace for INotebookShell type information.
19
+ */
20
+ export declare namespace INotebookShell {
21
+ /**
22
+ * The areas of the application shell where widgets can reside.
23
+ */
24
+ type Area = 'main' | 'top' | 'menu' | 'left' | 'right';
25
+ /**
26
+ * Widget position
27
+ */
28
+ interface IWidgetPosition {
29
+ /**
30
+ * Widget area
31
+ */
32
+ area?: Area;
33
+ /**
34
+ * Widget opening options
35
+ */
36
+ options?: DocumentRegistry.IOpenOptions;
37
+ }
38
+ /**
39
+ * Mapping of widget type identifier and their user customized position
40
+ */
41
+ interface IUserLayout {
42
+ /**
43
+ * Widget customized position
44
+ */
45
+ [k: string]: IWidgetPosition;
46
+ }
47
+ }
17
48
  /**
18
49
  * The application shell.
19
50
  */
@@ -60,6 +91,10 @@ export declare class NotebookShell extends Widget implements JupyterFrontEnd.ISh
60
91
  */
61
92
  get translator(): ITranslator;
62
93
  set translator(value: ITranslator);
94
+ /**
95
+ * User custom shell layout.
96
+ */
97
+ get userLayout(): any;
63
98
  /**
64
99
  * Activate a widget in its area.
65
100
  */
@@ -75,7 +110,7 @@ export declare class NotebookShell extends Widget implements JupyterFrontEnd.ISh
75
110
  * @param options - Optional open options.
76
111
  *
77
112
  */
78
- add(widget: Widget, area?: Shell.Area, options?: DocumentRegistry.IOpenOptions): void;
113
+ add(widget: Widget, area?: INotebookShell.Area, options?: DocumentRegistry.IOpenOptions): void;
79
114
  /**
80
115
  * Collapse the top area and the spacer to make the view more compact.
81
116
  */
@@ -89,7 +124,7 @@ export declare class NotebookShell extends Widget implements JupyterFrontEnd.ISh
89
124
  *
90
125
  * @param area The area
91
126
  */
92
- widgets(area: Shell.Area): IterableIterator<Widget>;
127
+ widgets(area: INotebookShell.Area): IterableIterator<Widget>;
93
128
  /**
94
129
  * Expand the left panel to show the sidebar with its widget.
95
130
  */
@@ -106,6 +141,10 @@ export declare class NotebookShell extends Widget implements JupyterFrontEnd.ISh
106
141
  * Collapse the right panel
107
142
  */
108
143
  collapseRight(): void;
144
+ /**
145
+ * Restore the layout state and configuration for the application shell.
146
+ */
147
+ restoreLayout(configuration: INotebookShell.IUserLayout): Promise<void>;
109
148
  private _topWrapper;
110
149
  private _topHandler;
111
150
  private _menuWrapper;
@@ -119,15 +158,7 @@ export declare class NotebookShell extends Widget implements JupyterFrontEnd.ISh
119
158
  private _translator;
120
159
  private _currentChanged;
121
160
  private _mainWidgetLoaded;
122
- }
123
- /**
124
- * A namespace for Shell statics
125
- */
126
- export declare namespace Shell {
127
- /**
128
- * The areas of the application shell where widgets can reside.
129
- */
130
- type Area = 'main' | 'top' | 'left' | 'right' | 'menu';
161
+ private _userLayout;
131
162
  }
132
163
  export declare namespace Private {
133
164
  class SkipLinkWidgetHandler {
package/lib/shell.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // Distributed under the terms of the Modified BSD License.
3
3
  import { nullTranslator } from '@jupyterlab/translation';
4
4
  import { find } from '@lumino/algorithm';
5
- import { PromiseDelegate, Token } from '@lumino/coreutils';
5
+ import { JSONExt, PromiseDelegate, Token } from '@lumino/coreutils';
6
6
  import { Signal } from '@lumino/signaling';
7
7
  import { BoxLayout, Panel, SplitPanel, Widget } from '@lumino/widgets';
8
8
  import { PanelHandler, SidePanelHandler } from './panelhandler';
@@ -24,6 +24,7 @@ export class NotebookShell extends Widget {
24
24
  this._currentChanged = new Signal(this);
25
25
  this._mainWidgetLoaded = new PromiseDelegate();
26
26
  this.id = 'main';
27
+ this._userLayout = {};
27
28
  this._topHandler = new PanelHandler();
28
29
  this._menuHandler = new PanelHandler();
29
30
  this._leftHandler = new SidePanelHandler('left');
@@ -164,6 +165,12 @@ export class NotebookShell extends Widget {
164
165
  this._rightHandler.closeButton.title = trans.__('Collapse %1 side panel', this._rightHandler.area);
165
166
  }
166
167
  }
168
+ /**
169
+ * User custom shell layout.
170
+ */
171
+ get userLayout() {
172
+ return JSONExt.deepCopy(this._userLayout);
173
+ }
167
174
  /**
168
175
  * Activate a widget in its area.
169
176
  */
@@ -196,8 +203,23 @@ export class NotebookShell extends Widget {
196
203
  *
197
204
  */
198
205
  add(widget, area, options) {
199
- var _a;
200
- const rank = (_a = options === null || options === void 0 ? void 0 : options.rank) !== null && _a !== void 0 ? _a : DEFAULT_RANK;
206
+ var _a, _b;
207
+ let userPosition;
208
+ if ((options === null || options === void 0 ? void 0 : options.type) && this._userLayout[options.type]) {
209
+ userPosition = this._userLayout[options.type];
210
+ }
211
+ else {
212
+ userPosition = this._userLayout[widget.id];
213
+ }
214
+ area = (_a = userPosition === null || userPosition === void 0 ? void 0 : userPosition.area) !== null && _a !== void 0 ? _a : area;
215
+ options =
216
+ options || (userPosition === null || userPosition === void 0 ? void 0 : userPosition.options)
217
+ ? {
218
+ ...options,
219
+ ...userPosition === null || userPosition === void 0 ? void 0 : userPosition.options,
220
+ }
221
+ : undefined;
222
+ const rank = (_b = options === null || options === void 0 ? void 0 : options.rank) !== null && _b !== void 0 ? _b : DEFAULT_RANK;
201
223
  switch (area) {
202
224
  case 'top':
203
225
  return this._topHandler.addWidget(widget, rank);
@@ -291,6 +313,12 @@ export class NotebookShell extends Widget {
291
313
  this._rightHandler.collapse();
292
314
  this._rightHandler.panel.hide();
293
315
  }
316
+ /**
317
+ * Restore the layout state and configuration for the application shell.
318
+ */
319
+ async restoreLayout(configuration) {
320
+ this._userLayout = configuration;
321
+ }
294
322
  }
295
323
  export var Private;
296
324
  (function (Private) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter-notebook/application",
3
- "version": "7.0.0-beta.4",
3
+ "version": "7.0.0-rc.0",
4
4
  "description": "Jupyter Notebook - Application",
5
5
  "homepage": "https://github.com/jupyter/notebook",
6
6
  "bugs": {
@@ -42,11 +42,11 @@
42
42
  "watch": "tsc -b --watch"
43
43
  },
44
44
  "dependencies": {
45
- "@jupyterlab/application": "^4.0.1",
46
- "@jupyterlab/coreutils": "^6.0.1",
47
- "@jupyterlab/docregistry": "^4.0.1",
48
- "@jupyterlab/rendermime-interfaces": "^3.8.1",
49
- "@jupyterlab/ui-components": "^4.0.1",
45
+ "@jupyterlab/application": "^4.0.2",
46
+ "@jupyterlab/coreutils": "^6.0.2",
47
+ "@jupyterlab/docregistry": "^4.0.2",
48
+ "@jupyterlab/rendermime-interfaces": "^3.8.2",
49
+ "@jupyterlab/ui-components": "^4.0.2",
50
50
  "@lumino/algorithm": "^2.0.0",
51
51
  "@lumino/coreutils": "^2.1.1",
52
52
  "@lumino/messaging": "^2.0.0",
@@ -57,7 +57,7 @@
57
57
  "devDependencies": {
58
58
  "@babel/core": "^7.11.6",
59
59
  "@babel/preset-env": "^7.12.1",
60
- "@jupyterlab/testutils": "^4.0.1",
60
+ "@jupyterlab/testutils": "^4.0.2",
61
61
  "@types/jest": "^29.2.5",
62
62
  "jest": "^29.3.1",
63
63
  "rimraf": "^3.0.2",