Skip to content

Add the Show Header command to the command palette #6401

@jtpio

Description

@jtpio

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:

/**
* 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:

if (palette) {
palette.addItem({ command: CommandIDs.toggleZen, category: 'Mode' });
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions