mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-09 03:50:45 +08:00
Toggle header visibility
This commit is contained in:
parent
6646ce5def
commit
3185922bb3
@ -44,7 +44,9 @@
|
||||
"@jupyterlab/codemirror": "^3.0.0-rc.12",
|
||||
"@jupyterlab/docregistry": "^3.0.0-rc.12",
|
||||
"@jupyterlab/docmanager": "^3.0.0-rc.12",
|
||||
"@jupyterlab/mainmenu": "^3.0.0-rc.12",
|
||||
"@jupyterlab/notebook": "^3.0.0-rc.12",
|
||||
"@jupyterlab/settingregistry": "^3.0.0-rc.12",
|
||||
"@jupyterlab/translation": "^3.0.0-rc.12",
|
||||
"@lumino/widgets": "^1.14.0"
|
||||
},
|
||||
|
@ -19,6 +19,8 @@ import { PageConfig, Text, Time } from '@jupyterlab/coreutils';
|
||||
|
||||
import { IDocumentManager, renameDialog } from '@jupyterlab/docmanager';
|
||||
|
||||
import { IMainMenu } from '@jupyterlab/mainmenu';
|
||||
|
||||
import { NotebookPanel } from '@jupyterlab/notebook';
|
||||
|
||||
import { ITranslator, TranslationManager } from '@jupyterlab/translation';
|
||||
@ -62,7 +64,10 @@ const KERNEL_STATUS_FADE_OUT_CLASS = 'jp-ClassicKernelStatus-fade';
|
||||
* The command IDs used by the application plugin.
|
||||
*/
|
||||
namespace CommandIDs {
|
||||
export const open = 'docmanager:open';
|
||||
/**
|
||||
* Toggle Top Bar visibility
|
||||
*/
|
||||
export const toggleTop = 'application:toggle-top';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -391,6 +396,35 @@ const title: JupyterFrontEndPlugin<void> = {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Plugin to toggle the top header visibility.
|
||||
*/
|
||||
const topVisibility: JupyterFrontEndPlugin<void> = {
|
||||
id: '@jupyterlab-classic/application-extension:top',
|
||||
requires: [IClassicShell],
|
||||
optional: [IMainMenu],
|
||||
activate: (
|
||||
app: JupyterFrontEnd<JupyterFrontEnd.IShell>,
|
||||
classicShell: IClassicShell,
|
||||
menu: IMainMenu | null
|
||||
) => {
|
||||
const top = classicShell.top;
|
||||
|
||||
app.commands.addCommand(CommandIDs.toggleTop, {
|
||||
label: 'Show Header',
|
||||
execute: (args: any) => {
|
||||
top.setHidden(top.isVisible);
|
||||
},
|
||||
isToggled: () => top.isVisible
|
||||
});
|
||||
|
||||
if (menu) {
|
||||
menu.viewMenu.addGroup([{ command: CommandIDs.toggleTop }], 2);
|
||||
}
|
||||
},
|
||||
autoStart: true
|
||||
};
|
||||
|
||||
/**
|
||||
* A simplified Translator
|
||||
*/
|
||||
@ -426,7 +460,7 @@ const tree: JupyterFrontEndPlugin<void> = {
|
||||
const [, path] = matches;
|
||||
|
||||
app.restored.then(() => {
|
||||
commands.execute(CommandIDs.open, {
|
||||
commands.execute('docmanager:open', {
|
||||
path,
|
||||
factory: NOTEBOOK_FACTORY
|
||||
});
|
||||
@ -453,6 +487,7 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
|
||||
shell,
|
||||
spacer,
|
||||
title,
|
||||
topVisibility,
|
||||
translator,
|
||||
tree
|
||||
];
|
||||
|
@ -114,6 +114,13 @@ export class ClassicShell extends Widget implements JupyterFrontEnd.IShell {
|
||||
return this._main.widgets[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the top area panel
|
||||
*/
|
||||
get top(): Widget {
|
||||
return this._topHandler.panel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of widgets for the given area.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user