Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document process of adding new commands to the command palette #14826

Open
g547315 opened this issue Jul 13, 2023 · 1 comment
Open

Document process of adding new commands to the command palette #14826

g547315 opened this issue Jul 13, 2023 · 1 comment

Comments

@g547315
Copy link
Contributor

g547315 commented Jul 13, 2023

Problem

When doing development work on adding new accessibility commands to the command palette I would like it if there was a documented process for this

Proposed Solution

Here is a draft:
To add new command to the command palette of Jupyter please follow these steps:

  1. Navigate to: packages/application-extension/src/index.tsx

  2. create a command IDs used by the application plugin as exported variable (find examples in file)
    export const <new command name>: string = 'application:<new command name>';

  3. create a function that detailed the functionality of the knew command being added
    commands.addCommand(CommandIDs.<command ID created in step 2>, {
    label: () => trans.__('<short description of the command>'),
    execute: () => {
    // new command functionality code here
    },
    });

  4. add command to the if palette statement block
    if (palette) {
    ....
    CommandIDs.<command ID created> }

  5. Now navigate to packages/application-extension/schema/commands.json

  6. Add a new json object in the format
    {

    "command": "application:<new command name>",
    "keys": ["<keyboard shortcut combination>"], // shortcut key that will be linked to the command
    "selector": "body"// which locations in the app can said command be called from

    },
    `

Finally further is needed around:

  • Guidance on names convention for the command
  • Guidance on selecting the the combination keys for the a new command
  • Please indicate where this documentation would live

Additional context

There is this video on how to override a command which doesn't really cover adding new commands to the
keyboard-shortcuts

There is also a list of commands which doesn't really cover the request
User commands

_*ps this is a first draft, please leave feedback and comments

@jupyterlab-probot jupyterlab-probot bot added the status:Needs Triage Applied to new issues that need triage label Jul 13, 2023
@krassowski
Copy link
Member

Thank you for sharing your notes! There is a command palette extension example here: https://github.com/jupyterlab/extension-examples/tree/main/command-palette. It could be extended with adding shortcut, but this is really a separate thing from adding a command.

Importantly, commands may belong to different packages so your suggestion about a documentation specific to adding a command to application-extension may not be generic enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants