1 | import { DocumentRegistry } from '@jupyterlab/docregistry';
|
2 | import { ITranslator } from '@jupyterlab/translation';
|
3 | import { Token } from '@lumino/coreutils';
|
4 | import { Message } from '@lumino/messaging';
|
5 | import { ISignal } from '@lumino/signaling';
|
6 | import { DockLayout, DockPanel, FocusTracker, TabBar, Widget } from '@lumino/widgets';
|
7 | import { JupyterFrontEnd } from './frontend';
|
8 | import { LayoutRestorer } from './layoutrestorer';
|
9 | /**
|
10 | * The JupyterLab application shell token.
|
11 | */
|
12 | export declare const ILabShell: Token<ILabShell>;
|
13 | /**
|
14 | * The JupyterLab application shell interface.
|
15 | */
|
16 | export interface ILabShell extends LabShell {
|
17 | }
|
18 | /**
|
19 | * The namespace for `ILabShell` type information.
|
20 | */
|
21 | export declare namespace ILabShell {
|
22 | /**
|
23 | * The areas of the application shell where widgets can reside.
|
24 | */
|
25 | type Area = 'main' | 'header' | 'top' | 'menu' | 'left' | 'right' | 'bottom' | 'down';
|
26 | /**
|
27 | * The restorable description of an area within the main dock panel.
|
28 | */
|
29 | type AreaConfig = DockLayout.AreaConfig;
|
30 | /**
|
31 | * An options object for creating a lab shell object.
|
32 | */
|
33 | type IOptions = {
|
34 | /**
|
35 | * Whether the layout should wait to be restored before adding widgets or not.
|
36 | *
|
37 | * #### Notes
|
38 | * It defaults to true
|
39 | */
|
40 | waitForRestore?: boolean;
|
41 | };
|
42 | /**
|
43 | * An arguments object for the changed signals.
|
44 | */
|
45 | type IChangedArgs = FocusTracker.IChangedArgs<Widget>;
|
46 | interface IConfig {
|
47 | /**
|
48 | * The method for hiding widgets in the dock panel.
|
49 | *
|
50 | * The default is `display`.
|
51 | *
|
52 | * Using `scale` will often increase performance as most browsers will not trigger style computation
|
53 | * for the transform action.
|
54 | *
|
55 | * `contentVisibility` is only available in Chromium-based browsers.
|
56 | */
|
57 | hiddenMode: 'display' | 'scale' | 'contentVisibility';
|
58 | }
|
59 | /**
|
60 | * Widget position
|
61 | */
|
62 | interface IWidgetPosition {
|
63 | /**
|
64 | * Widget area
|
65 | */
|
66 | area?: Area;
|
67 | /**
|
68 | * Widget opening options
|
69 | */
|
70 | options?: DocumentRegistry.IOpenOptions;
|
71 | }
|
72 | /**
|
73 | * To-be-added widget and associated position
|
74 | */
|
75 | interface IDelayedWidget extends IWidgetPosition {
|
76 | widget: Widget;
|
77 | }
|
78 | /**
|
79 | * Mapping of widget type identifier and their user customized position
|
80 | */
|
81 | interface IUserLayout {
|
82 | /**
|
83 | * Widget customized position
|
84 | */
|
85 | [k: string]: IWidgetPosition;
|
86 | }
|
87 | /**
|
88 | * The args for the current path change signal.
|
89 | */
|
90 | interface ICurrentPathChangedArgs {
|
91 | /**
|
92 | * The new value of the tree path, not including '/tree'.
|
93 | */
|
94 | oldValue: string;
|
95 | /**
|
96 | * The old value of the tree path, not including '/tree'.
|
97 | */
|
98 | newValue: string;
|
99 | }
|
100 | /**
|
101 | * A description of the application's user interface layout.
|
102 | */
|
103 | interface ILayout {
|
104 | /**
|
105 | * Indicates whether fetched session restore data was actually retrieved
|
106 | * from the state database or whether it is a fresh blank slate.
|
107 | *
|
108 | * #### Notes
|
109 | * This attribute is only relevant when the layout data is retrieved via a
|
110 | * `fetch` call. If it is set when being passed into `save`, it will be
|
111 | * ignored.
|
112 | */
|
113 | readonly fresh?: boolean;
|
114 | /**
|
115 | * The main area of the user interface.
|
116 | */
|
117 | readonly mainArea: IMainArea | null;
|
118 | /**
|
119 | * The down area of the user interface.
|
120 | */
|
121 | readonly downArea: IDownArea | null;
|
122 | /**
|
123 | * The left area of the user interface.
|
124 | */
|
125 | readonly leftArea: ISideArea | null;
|
126 | /**
|
127 | * The right area of the user interface.
|
128 | */
|
129 | readonly rightArea: ISideArea | null;
|
130 | /**
|
131 | * The top area of the user interface.
|
132 | */
|
133 | readonly topArea: ITopArea | null;
|
134 | /**
|
135 | * The relatives sizes of the areas of the user interface.
|
136 | */
|
137 | readonly relativeSizes: number[] | null;
|
138 | }
|
139 | /**
|
140 | * The restorable description of the main application area.
|
141 | */
|
142 | interface IMainArea {
|
143 | /**
|
144 | * The current widget that has application focus.
|
145 | */
|
146 | readonly currentWidget: Widget | null;
|
147 | /**
|
148 | * The contents of the main application dock panel.
|
149 | */
|
150 | readonly dock: DockLayout.ILayoutConfig | null;
|
151 | }
|
152 | interface IDownArea {
|
153 | /**
|
154 | * The current widget that has down area focus.
|
155 | */
|
156 | readonly currentWidget: Widget | null;
|
157 | /**
|
158 | * The collection of widgets held by the panel.
|
159 | */
|
160 | readonly widgets: Array<Widget> | null;
|
161 | /**
|
162 | * Vertical relative size of the down area
|
163 | *
|
164 | * The main area will take the rest of the height
|
165 | */
|
166 | readonly size: number | null;
|
167 | }
|
168 | /**
|
169 | * The restorable description of a sidebar in the user interface.
|
170 | */
|
171 | interface ISideArea {
|
172 | /**
|
173 | * A flag denoting whether the sidebar has been collapsed.
|
174 | */
|
175 | readonly collapsed: boolean;
|
176 | /**
|
177 | * The current widget that has side area focus.
|
178 | */
|
179 | readonly currentWidget: Widget | null;
|
180 | /**
|
181 | * A flag denoting whether the side tab bar is visible.
|
182 | */
|
183 | readonly visible: boolean;
|
184 | /**
|
185 | * The collection of widgets held by the sidebar.
|
186 | */
|
187 | readonly widgets: Array<Widget> | null;
|
188 | /**
|
189 | * The collection of widgets states held by the sidebar.
|
190 | */
|
191 | readonly widgetStates: {
|
192 | [id: string]: {
|
193 | /**
|
194 | * Vertical sizes of the widgets.
|
195 | */
|
196 | readonly sizes: Array<number> | null;
|
197 | /**
|
198 | * Expansion states of the widgets.
|
199 | */
|
200 | readonly expansionStates: Array<boolean> | null;
|
201 | };
|
202 | };
|
203 | }
|
204 | /**
|
205 | * The restorable description of the top area in the user interface.
|
206 | */
|
207 | interface ITopArea {
|
208 | /**
|
209 | * Top area visibility in simple mode.
|
210 | */
|
211 | readonly simpleVisibility: boolean;
|
212 | }
|
213 | }
|
214 | /**
|
215 | * The restorable description of the top area in the user interface.
|
216 | *
|
217 | * @deprecated It has been moved to {@link ILabShell.ITopArea} for consistency.
|
218 | */
|
219 | export interface ITopArea extends ILabShell.ITopArea {
|
220 | }
|
221 | /**
|
222 | * The application shell for JupyterLab.
|
223 | */
|
224 | export declare class LabShell extends Widget implements JupyterFrontEnd.IShell {
|
225 | /**
|
226 | * Construct a new application shell.
|
227 | */
|
228 | constructor(options?: ILabShell.IOptions);
|
229 | /**
|
230 | * A signal emitted when main area's active focus changes.
|
231 | */
|
232 | get activeChanged(): ISignal<this, ILabShell.IChangedArgs>;
|
233 | /**
|
234 | * The active widget in the shell's main area.
|
235 | */
|
236 | get activeWidget(): Widget | null;
|
237 | /**
|
238 | * Whether the add buttons for each main area tab bar are enabled.
|
239 | */
|
240 | get addButtonEnabled(): boolean;
|
241 | set addButtonEnabled(value: boolean);
|
242 | /**
|
243 | * A signal emitted when the add button on a main area tab bar is clicked.
|
244 | */
|
245 | get addRequested(): ISignal<DockPanel, TabBar<Widget>>;
|
246 | /**
|
247 | * A signal emitted when main area's current focus changes.
|
248 | */
|
249 | get currentChanged(): ISignal<this, ILabShell.IChangedArgs>;
|
250 | /**
|
251 | * Current document path.
|
252 | */
|
253 | get currentPath(): string | null | undefined;
|
254 | /**
|
255 | * A signal emitted when the path of the current document changes.
|
256 | *
|
257 | * This also fires when the current document itself changes.
|
258 | */
|
259 | get currentPathChanged(): ISignal<this, ILabShell.ICurrentPathChangedArgs>;
|
260 | /**
|
261 | * The current widget in the shell's main area.
|
262 | */
|
263 | get currentWidget(): Widget | null;
|
264 | /**
|
265 | * A signal emitted when the main area's layout is modified.
|
266 | */
|
267 | get layoutModified(): ISignal<this, void>;
|
268 | /**
|
269 | * Whether the left area is collapsed.
|
270 | */
|
271 | get leftCollapsed(): boolean;
|
272 | /**
|
273 | * Whether the left area is collapsed.
|
274 | */
|
275 | get rightCollapsed(): boolean;
|
276 | /**
|
277 | * Whether JupyterLab is in presentation mode with the
|
278 | * `jp-mod-presentationMode` CSS class.
|
279 | */
|
280 | get presentationMode(): boolean;
|
281 | set presentationMode(value: boolean);
|
282 | /**
|
283 | * The main dock area's user interface mode.
|
284 | */
|
285 | get mode(): DockPanel.Mode;
|
286 | set mode(mode: DockPanel.Mode);
|
287 | /**
|
288 | * A signal emitted when the shell/dock panel change modes (single/multiple document).
|
289 | */
|
290 | get modeChanged(): ISignal<this, DockPanel.Mode>;
|
291 | /**
|
292 | * Promise that resolves when state is first restored, returning layout
|
293 | * description.
|
294 | */
|
295 | get restored(): Promise<ILabShell.ILayout>;
|
296 | get translator(): ITranslator;
|
297 | set translator(value: ITranslator);
|
298 | /**
|
299 | * User customized shell layout.
|
300 | */
|
301 | get userLayout(): {
|
302 | 'single-document': ILabShell.IUserLayout;
|
303 | 'multiple-document': ILabShell.IUserLayout;
|
304 | };
|
305 | /**
|
306 | * Activate a widget in its area.
|
307 | */
|
308 | activateById(id: string): void;
|
309 | /**
|
310 | * Activate widget in specified area.
|
311 | *
|
312 | * ### Notes
|
313 | * The alpha version of this method only supports activating the "main" area.
|
314 | *
|
315 | * @alpha
|
316 | * @param area Name of area to activate
|
317 | */
|
318 | activateArea(area?: ILabShell.Area): void;
|
319 | /**
|
320 | * Activate the next Tab in the active TabBar.
|
321 | */
|
322 | activateNextTab(): void;
|
323 | /**
|
324 | * Activate the previous Tab in the active TabBar.
|
325 | */
|
326 | activatePreviousTab(): void;
|
327 | /**
|
328 | * Activate the next TabBar.
|
329 | */
|
330 | activateNextTabBar(): void;
|
331 | /**
|
332 | * Activate the next TabBar.
|
333 | */
|
334 | activatePreviousTabBar(): void;
|
335 | /**
|
336 | * Add a widget to the JupyterLab shell
|
337 | *
|
338 | * @param widget Widget
|
339 | * @param area Area
|
340 | * @param options Options
|
341 | */
|
342 | add(widget: Widget, area?: ILabShell.Area, options?: DocumentRegistry.IOpenOptions): void;
|
343 | /**
|
344 | * Move a widget type to a new area.
|
345 | *
|
346 | * The type is determined from the `widget.id` and fallback to `widget.id`.
|
347 | *
|
348 | * #### Notes
|
349 | * If `mode` is undefined, both mode are updated.
|
350 | * The new layout is now persisted.
|
351 | *
|
352 | * @param widget Widget to move
|
353 | * @param area New area
|
354 | * @param mode Mode to change
|
355 | * @returns The new user layout
|
356 | */
|
357 | move(widget: Widget, area: ILabShell.Area, mode?: DockPanel.Mode): {
|
358 | 'single-document': ILabShell.IUserLayout;
|
359 | 'multiple-document': ILabShell.IUserLayout;
|
360 | };
|
361 | /**
|
362 | * Collapse the left area.
|
363 | */
|
364 | collapseLeft(): void;
|
365 | /**
|
366 | * Collapse the right area.
|
367 | */
|
368 | collapseRight(): void;
|
369 | /**
|
370 | * Dispose the shell.
|
371 | */
|
372 | dispose(): void;
|
373 | /**
|
374 | * Expand the left area.
|
375 | *
|
376 | * #### Notes
|
377 | * This will open the most recently used tab,
|
378 | * or the first tab if there is no most recently used.
|
379 | */
|
380 | expandLeft(): void;
|
381 | /**
|
382 | * Expand the right area.
|
383 | *
|
384 | * #### Notes
|
385 | * This will open the most recently used tab,
|
386 | * or the first tab if there is no most recently used.
|
387 | */
|
388 | expandRight(): void;
|
389 | /**
|
390 | * Close all widgets in the main and down area.
|
391 | */
|
392 | closeAll(): void;
|
393 | /**
|
394 | * Whether an side tab bar is visible or not.
|
395 | *
|
396 | * @param side Sidebar of interest
|
397 | * @returns Side tab bar visibility
|
398 | */
|
399 | isSideTabBarVisible(side: 'left' | 'right'): boolean;
|
400 | /**
|
401 | * Whether the top bar in simple mode is visible or not.
|
402 | *
|
403 | * @returns Top bar visibility
|
404 | */
|
405 | isTopInSimpleModeVisible(): boolean;
|
406 | /**
|
407 | * True if the given area is empty.
|
408 | */
|
409 | isEmpty(area: ILabShell.Area): boolean;
|
410 | /**
|
411 | * Restore the layout state and configuration for the application shell.
|
412 | *
|
413 | * #### Notes
|
414 | * This should only be called once.
|
415 | */
|
416 | restoreLayout(mode: DockPanel.Mode, layoutRestorer: LayoutRestorer, configuration?: {
|
417 | [m: string]: ILabShell.IUserLayout;
|
418 | }): Promise<void>;
|
419 | /**
|
420 | * Save the dehydrated state of the application shell.
|
421 | */
|
422 | saveLayout(): ILabShell.ILayout;
|
423 | /**
|
424 | * Toggle top header visibility in simple mode
|
425 | *
|
426 | * Note: Does nothing in multi-document mode
|
427 | */
|
428 | toggleTopInSimpleModeVisibility(): void;
|
429 | /**
|
430 | * Toggle side tab bar visibility
|
431 | *
|
432 | * @param side Sidebar of interest
|
433 | */
|
434 | toggleSideTabBarVisibility(side: 'right' | 'left'): void;
|
435 | /**
|
436 | * Update the shell configuration.
|
437 | *
|
438 | * @param config Shell configuration
|
439 | */
|
440 | updateConfig(config: Partial<ILabShell.IConfig>): void;
|
441 | /**
|
442 | * Returns the widgets for an application area.
|
443 | */
|
444 | widgets(area?: ILabShell.Area): IterableIterator<Widget>;
|
445 | /**
|
446 | * Handle `after-attach` messages for the application shell.
|
447 | */
|
448 | protected onAfterAttach(msg: Message): void;
|
449 | /**
|
450 | * Update the title panel title based on the title of the current widget.
|
451 | */
|
452 | private _updateTitlePanelTitle;
|
453 | /**
|
454 | * The path of the current widget changed, fire the _currentPathChanged signal.
|
455 | */
|
456 | private _updateCurrentPath;
|
457 | /**
|
458 | * Add a widget to the left content area.
|
459 | *
|
460 | * #### Notes
|
461 | * Widgets must have a unique `id` property, which will be used as the DOM id.
|
462 | */
|
463 | private _addToLeftArea;
|
464 | /**
|
465 | * Add a widget to the main content area.
|
466 | *
|
467 | * #### Notes
|
468 | * Widgets must have a unique `id` property, which will be used as the DOM id.
|
469 | * All widgets added to the main area should be disposed after removal
|
470 | * (disposal before removal will remove the widget automatically).
|
471 | *
|
472 | * In the options, `ref` defaults to `null`, `mode` defaults to `'tab-after'`,
|
473 | * and `activate` defaults to `true`.
|
474 | */
|
475 | private _addToMainArea;
|
476 | /**
|
477 | * Add a widget to the right content area.
|
478 | *
|
479 | * #### Notes
|
480 | * Widgets must have a unique `id` property, which will be used as the DOM id.
|
481 | */
|
482 | private _addToRightArea;
|
483 | /**
|
484 | * Add a widget to the top content area.
|
485 | *
|
486 | * #### Notes
|
487 | * Widgets must have a unique `id` property, which will be used as the DOM id.
|
488 | */
|
489 | private _addToTopArea;
|
490 | /**
|
491 | * Add a widget to the title content area.
|
492 | *
|
493 | * #### Notes
|
494 | * Widgets must have a unique `id` property, which will be used as the DOM id.
|
495 | */
|
496 | private _addToMenuArea;
|
497 | /**
|
498 | * Add a widget to the header content area.
|
499 | *
|
500 | * #### Notes
|
501 | * Widgets must have a unique `id` property, which will be used as the DOM id.
|
502 | */
|
503 | private _addToHeaderArea;
|
504 | /**
|
505 | * Add a widget to the bottom content area.
|
506 | *
|
507 | * #### Notes
|
508 | * Widgets must have a unique `id` property, which will be used as the DOM id.
|
509 | */
|
510 | private _addToBottomArea;
|
511 | private _addToDownArea;
|
512 | private _adjacentBar;
|
513 | private _currentTabBar;
|
514 | /**
|
515 | * Handle a change to the dock area active widget.
|
516 | */
|
517 | private _onActiveChanged;
|
518 | /**
|
519 | * Handle a change to the dock area current widget.
|
520 | */
|
521 | private _onCurrentChanged;
|
522 | /**
|
523 | * Handle a change on the down panel widgets
|
524 | */
|
525 | private _onTabPanelChanged;
|
526 | /**
|
527 | * Handle a change to the layout.
|
528 | */
|
529 | private _onLayoutModified;
|
530 | /**
|
531 | * A message hook for child add/remove messages on the main area dock panel.
|
532 | */
|
533 | private _dockChildHook;
|
534 | private _activeChanged;
|
535 | private _cachedLayout;
|
536 | private _currentChanged;
|
537 | private _currentPath;
|
538 | private _currentPathChanged;
|
539 | private _modeChanged;
|
540 | private _dockPanel;
|
541 | private _downPanel;
|
542 | private _isRestored;
|
543 | private _layoutModified;
|
544 | private _layoutDebouncer;
|
545 | private _leftHandler;
|
546 | private _restored;
|
547 | private _rightHandler;
|
548 | private _tracker;
|
549 | private _headerPanel;
|
550 | private _hsplitPanel;
|
551 | private _vsplitPanel;
|
552 | private _topHandler;
|
553 | private _topHandlerHiddenByUser;
|
554 | private _menuHandler;
|
555 | private _skipLinkWidget;
|
556 | private _titleHandler;
|
557 | private _bottomPanel;
|
558 | private _idTypeMap;
|
559 | private _mainOptionsCache;
|
560 | private _sideOptionsCache;
|
561 | private _userLayout;
|
562 | private _delayedWidget;
|
563 | private _translator;
|
564 | private _layoutRestorer;
|
565 | }
|