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.
- Add a new config option to dev namespace in
DendronDevConfigunderpackages/common-all/src/types/workspace.ts,packages/common-all/src/types/configs/dev/dev.tsandpackages/common-all/src/constants/configs/dev.ts. - Add your own context to
DendronContextinpackages/plugin-core/src/constants.tsfor enablement of the command. Set the Context with the config created in the first step inpackages/plugin-core/src/_extension.tsIn the example PR, see:
VSCodeUtils.setContext(
DendronContext.ENABLE_EXPORT_PODV2,
dendronConfig.dev?.enableExportPodV2 ?? false
);
- In
DENDRON_COMMANDSunderplugin-core/src/constants.ts, update the when/enablement clause of the desired command with the context created in above step. - Open the command prompt, enter
Run Task, and rungen:config- this will update the command in
package.json
- this will update the command in
- Manually test with test-workspace, the command should only be visible in command palette if config option is set to true.
Backlinks