-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Closed
Milestone
Description
Problem
The Show Header command is available as a menu item:
show-header-command.mp4
However it is not available in the command palette.
Proposed Solution
The plugin adding the command is defined here:
notebook/packages/application-extension/src/index.ts
Lines 424 to 463 in 9e81700
| /** | |
| * Plugin to toggle the top header visibility. | |
| */ | |
| const topVisibility: JupyterFrontEndPlugin<void> = { | |
| id: '@retrolab/application-extension:top', | |
| requires: [IRetroShell], | |
| optional: [IMainMenu], | |
| activate: ( | |
| app: JupyterFrontEnd<JupyterFrontEnd.IShell>, | |
| retroShell: IRetroShell, | |
| menu: IMainMenu | null | |
| ) => { | |
| const top = retroShell.top; | |
| app.commands.addCommand(CommandIDs.toggleTop, { | |
| label: 'Show Header', | |
| execute: () => { | |
| top.setHidden(top.isVisible); | |
| }, | |
| isToggled: () => top.isVisible | |
| }); | |
| if (menu) { | |
| menu.viewMenu.addGroup([{ command: CommandIDs.toggleTop }], 2); | |
| } | |
| const onChanged = (): void => { | |
| if (app.format === 'desktop') { | |
| retroShell.expandTop(); | |
| } else { | |
| retroShell.collapseTop(); | |
| } | |
| }; | |
| // listen on format change (mobile and desktop) to make the view more compact | |
| app.formatChanged.connect(onChanged); | |
| onChanged(); | |
| }, | |
| autoStart: true | |
| }; |
We'll need to add the optional ICommandPalette to add the command to the palette if available.
As an example implementation, the command to toggle zen mode is added to the palette here:
notebook/packages/application-extension/src/index.ts
Lines 526 to 528 in 9e81700
| if (palette) { | |
| palette.addItem({ command: CommandIDs.toggleZen, category: 'Mode' }); | |
| } |