-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathShowMarkdownPreviewExecuteStep.ts
More file actions
25 lines (21 loc) · 1.31 KB
/
ShowMarkdownPreviewExecuteStep.ts
File metadata and controls
25 lines (21 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { nonNullProp } from "@microsoft/vscode-azext-utils";
import { assertTemplateIsV2 } from "../../../utils/templateVersionUtils";
import { showMarkdownPreviewContent } from "../../../utils/textUtils";
import { getWorkspaceSetting } from "../../../vsCodeConfig/settings";
import { type FunctionV2WizardContext } from "../IFunctionWizardContext";
import { ActionSchemaStepBase } from "./ActionSchemaStepBase";
export class ShowMarkdownPreviewExecuteStep<T extends FunctionV2WizardContext> extends ActionSchemaStepBase<T> {
public async executeAction(context: T): Promise<void> {
assertTemplateIsV2(context.functionTemplate);
const filename = nonNullProp(this.action, 'filePath');
const content = context.functionTemplate.files[filename] ?? '';
await showMarkdownPreviewContent(content, filename, /* openToSide: */ true);
}
public shouldExecute(_context: T): boolean {
return !!getWorkspaceSetting('showMarkdownPreview');
}
}