Set the notebook name in the browser tab title

pull/6294/head
Jeremy Tuloup 5 years ago
parent 44654f03c5
commit d73b552f48

@ -106,6 +106,7 @@ class ClassicApp(NBClassicConfigShimMixin, LabServerApp):
description = "JupyterLab Classic - A JupyterLab Distribution with the Classic Notebook look and feel"
app_version = version
extension_url = "/classic/tree"
default_url = "/classic/tree"
load_other_extensions = True
app_dir = app_dir
app_settings_dir = pjoin(app_dir, "settings")

@ -284,6 +284,32 @@ const spacer: JupyterFrontEndPlugin<void> = {
}
};
/**
* A plugin to display the document title in the browser tab title
*/
const tabTitle: JupyterFrontEndPlugin<void> = {
id: '@jupyterlab-classic/application-extension:tab-title',
autoStart: true,
requires: [IClassicShell],
activate: (app: JupyterFrontEnd, shell: IClassicShell) => {
const setTabTitle = () => {
const current = shell.currentWidget;
if (!(current instanceof DocumentWidget)) {
return;
}
const update = () => {
const basename = PathExt.basename(current.context.path);
document.title = basename;
};
current.context.pathChanged.connect(update);
update();
};
shell.currentChanged.connect(setTabTitle);
setTabTitle();
}
};
/**
* A plugin to display and rename the title of a file
*/
@ -472,6 +498,7 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
sessionDialogs,
shell,
spacer,
tabTitle,
title,
topVisibility,
translator,

Loading…
Cancel
Save