Path: blob/main/extensions/markdown-language-features/src/commands/reopenAsPreview.ts
13389 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import * as vscode from 'vscode';6import { Command } from '../commandManager';78export class ReopenAsPreviewCommand implements Command {9public readonly id = 'markdown.reopenAsPreview';1011public async execute() {12await vscode.commands.executeCommand('reopenActiveEditorWith', 'vscode.markdown.preview.editor');13}14}1516export class ReopenAsSourceCommand implements Command {17public readonly id = 'markdown.reopenAsSource';1819public async execute() {20await vscode.commands.executeCommand('reopenActiveEditorWith', 'default');21}22}2324export class TogglePreviewCommand implements Command {25public readonly id = 'markdown.togglePreview';2627public async execute() {28if (vscode.window.activeTextEditor) {29// In source editor, switch to preview30await vscode.commands.executeCommand('reopenActiveEditorWith', 'vscode.markdown.preview.editor');31} else {32// In custom editor preview, switch to source33await vscode.commands.executeCommand('reopenActiveEditorWith', 'default');34}35}36}373839