Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/markdown-language-features/src/commands/reopenAsPreview.ts
13389 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import * as vscode from 'vscode';
7
import { Command } from '../commandManager';
8
9
export class ReopenAsPreviewCommand implements Command {
10
public readonly id = 'markdown.reopenAsPreview';
11
12
public async execute() {
13
await vscode.commands.executeCommand('reopenActiveEditorWith', 'vscode.markdown.preview.editor');
14
}
15
}
16
17
export class ReopenAsSourceCommand implements Command {
18
public readonly id = 'markdown.reopenAsSource';
19
20
public async execute() {
21
await vscode.commands.executeCommand('reopenActiveEditorWith', 'default');
22
}
23
}
24
25
export class TogglePreviewCommand implements Command {
26
public readonly id = 'markdown.togglePreview';
27
28
public async execute() {
29
if (vscode.window.activeTextEditor) {
30
// In source editor, switch to preview
31
await vscode.commands.executeCommand('reopenActiveEditorWith', 'vscode.markdown.preview.editor');
32
} else {
33
// In custom editor preview, switch to source
34
await vscode.commands.executeCommand('reopenActiveEditorWith', 'default');
35
}
36
}
37
}
38
39