From 56f85cd7d494e32220eb53f5ac758b48f51c7294 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Fri, 19 Apr 2024 16:45:05 +0000 Subject: [PATCH] For notebook windowing mode to `defer` --- packages/notebook-extension/src/index.ts | 25 +++++++--------------- packages/notebook-extension/style/base.css | 6 ++++++ 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/packages/notebook-extension/src/index.ts b/packages/notebook-extension/src/index.ts index 471b0984a9..9a9e08e95c 100644 --- a/packages/notebook-extension/src/index.ts +++ b/packages/notebook-extension/src/index.ts @@ -564,27 +564,18 @@ const editNotebookMetadata: JupyterFrontEndPlugin = { }; /** - * A plugin to set the default windowing mode for the notebook - * TODO: remove + * A plugin to set the default windowing mode to defer for the notebook + * TODO: remove? */ const windowing: JupyterFrontEndPlugin = { id: '@jupyter-notebook/notebook-extension:windowing', autoStart: true, - requires: [ISettingRegistry], - activate: (app: JupyterFrontEnd, settingRegistry: ISettingRegistry): void => { - // default to `none` to avoid notebook rendering glitches - const settings = settingRegistry.load( - '@jupyterlab/notebook-extension:tracker' - ); - Promise.all([settings, app.restored]) - .then(([settings]) => { - if (settings.user.windowing === undefined) { - void settings.set('windowingMode', 'defer'); - } - }) - .catch((reason: Error) => { - console.error(reason.message); - }); + requires: [INotebookTracker], + activate: (app: JupyterFrontEnd, notebookTracker: INotebookTracker): void => { + notebookTracker.widgetAdded.connect((sender, widget) => { + widget.content['_viewModel'].windowingActive = false; + widget.content.notebookConfig.windowingMode = 'defer'; + }); }, }; diff --git a/packages/notebook-extension/style/base.css b/packages/notebook-extension/style/base.css index 7d6010aa19..ae5d73c457 100644 --- a/packages/notebook-extension/style/base.css +++ b/packages/notebook-extension/style/base.css @@ -51,6 +51,12 @@ body[data-notebook='notebooks'] min-height: 100px; } +/* Workaround for disabling the full windowing mode */ +body[data-notebook='notebooks'] + .jp-Toolbar-item[data-jp-item-name='scrollbar'] { + display: none; +} + /* Fix background colors */ body[data-notebook='notebooks'] .jp-WindowedPanel-outer > * {