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
DendronDevConfig
underpackages/common-all/src/types/workspace.ts
,packages/common-all/src/types/configs/dev/dev.ts
andpackages/common-all/src/constants/configs/dev.ts
. - Add your own context to
DendronContext
inpackages/plugin-core/src/constants.ts
for enablement of the command. Set the Context with the config created in the first step inpackages/plugin-core/src/_extension.ts
In the example PR, see:
VSCodeUtils.setContext(
DendronContext.ENABLE_EXPORT_PODV2,
dendronConfig.dev?.enableExportPodV2 ?? false
);
- In
DENDRON_COMMANDS
underplugin-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