Add a Command in Preview

This section goes over adding a command in dev/preview. For an example, see this command. It adds Export Pod V2 commands in dev.

  1. Add a new config option to dev namespace in DendronDevConfig under packages/common-all/src/types/workspace.ts, packages/common-all/src/types/configs/dev/dev.ts and packages/common-all/src/constants/configs/dev.ts.
  2. Add your own context to DendronContext in packages/plugin-core/src/constants.ts for enablement of the command. Set the Context with the config created in the first step in packages/plugin-core/src/_extension.ts In the example PR, see:
VSCodeUtils.setContext(
  DendronContext.ENABLE_EXPORT_PODV2,
  dendronConfig.dev?.enableExportPodV2 ?? false
);
  1. In DENDRON_COMMANDS under plugin-core/src/constants.ts, update the when/enablement clause of the desired command with the context created in above step.
  2. Open the command prompt, enter Run Task, and run gen:config
    • this will update the command in package.json
  3. Manually test with test-workspace, the command should only be visible in command palette if config option is set to true.

Backlinks