Fix the ToC on Notebook (and remove remaining comments from rebase)

pull/6487/head
Nicolas Brichet 4 years ago committed by foo
parent b29a925ec2
commit a794e1287c

@ -83,6 +83,7 @@ async function main() {
require('@jupyterlab/apputils-extension').default.filter(({ id }) =>
[
'@jupyterlab/apputils-extension:palette',
'@jupyter/apputils-extension:sanitizer',
'@jupyterlab/apputils-extension:settings',
'@jupyterlab/apputils-extension:state',
'@jupyterlab/apputils-extension:themes',
@ -136,6 +137,7 @@ async function main() {
'@jupyterlab/notebook-extension:code-console',
'@jupyterlab/notebook-extension:export',
'@jupyterlab/notebook-extension:factory',
'@jupyterlab/notebook-extension:toc',
'@jupyterlab/notebook-extension:tracker',
'@jupyterlab/notebook-extension:widget-factory'
].includes(id)

@ -186,7 +186,7 @@ const opener: JupyterFrontEndPlugin<void> = {
const command = 'router:tree';
commands.addCommand(command, {
execute: (args: any) => {
execute: async (args: any) => {
const parsed = args as IRouter.ILocation;
const matches = parsed.path.match(TREE_PATTERN) ?? [];
const [, , path] = matches;
@ -196,12 +196,11 @@ const opener: JupyterFrontEndPlugin<void> = {
const file = decodeURIComponent(path);
const ext = PathExt.extname(file);
app.restored.then(async () => {
await new Promise(async () => {
// TODO: get factory from file type instead?
if (ext === '.ipynb') {
// TODO: fix upstream?
await settingRegistry?.load('@jupyterlab/notebook-extension:panel');
await Promise.resolve();
docManager.open(file, NOTEBOOK_FACTORY, undefined, {
ref: '_noref'
});

@ -34,6 +34,11 @@ export class NotebookApp extends JupyterFrontEnd<INotebookShell> {
this.registerPlugin(plugin);
}
}
this.restored = this.shell.restored
.then(() => undefined)
.catch(() => undefined);
this.restored.then(() => this._formatter.invoke());
}
@ -52,6 +57,12 @@ export class NotebookApp extends JupyterFrontEnd<INotebookShell> {
*/
readonly status = new LabStatus(this);
/**
* Promise that resolves when state is first restored, returning layout
* description.
*/
readonly restored: Promise<void>;
/**
* The version of the application.
*/

@ -6,7 +6,7 @@ import { PageConfig } from '@jupyterlab/coreutils';
import { DocumentRegistry } from '@jupyterlab/docregistry';
import { ArrayExt, find } from '@lumino/algorithm';
import { Token } from '@lumino/coreutils';
import { PromiseDelegate, Token } from '@lumino/coreutils';
import { Message, MessageLoop, IMessageHandler } from '@lumino/messaging';
import { Debouncer } from '@lumino/polling';
import { ISignal, Signal } from '@lumino/signaling';
@ -75,12 +75,10 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
} else {
this.layout = this.initLayoutWithoutSidePanels();
}
}
initLayoutWithoutSidePanels(): Layout {
const rootLayout = new BoxLayout();
BoxLayout.setStretch(this._main, 1);
this._spacer = new Widget();
@ -211,6 +209,13 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
return !(this._rightHandler.isVisible && this.rightPanel.isVisible);
}
/**
* Promise that resolves when main widget is loaded
*/
get restored(): Promise<void> {
return this._mainWidgetLoaded.promise;
}
/**
* Activate a widget in its area.
*/
@ -259,6 +264,7 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
this._main.addWidget(widget);
this._main.update();
this._currentChanged.emit(void 0);
this._mainWidgetLoaded.resolve();
break;
case 'left':
if (this.sidePanelsVisible()) {
@ -382,15 +388,6 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
}
}
/**
* Return the list of widgets for the given area.
*
* @param area The area
*/
// widgets(area?: string): IIterator<Widget> {
// return iter(this.widgetsList(area));
// }
/**
* Is a particular area empty (no widgets)?
*
@ -430,6 +427,7 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
private _spacer: Widget;
private _main: Panel;
private _currentChanged = new Signal<this, void>(this);
private _mainWidgetLoaded = new PromiseDelegate<void>();
}
/**

Loading…
Cancel
Save