Skip to content

Commit 18466db

Browse files
committed
Adds show markdown in editor
1 parent e86ace6 commit 18466db

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/system/-webview/markdown.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { TextDocumentShowOptions, Uri } from 'vscode';
2+
import { workspace } from 'vscode';
3+
import { Logger } from '../logger';
4+
import { executeCoreCommand } from './command';
5+
6+
export async function showMarkdownPreview(
7+
uriOrContent: Uri | string,
8+
options: TextDocumentShowOptions = {
9+
preview: false,
10+
},
11+
): Promise<void> {
12+
try {
13+
if (typeof uriOrContent === 'string') {
14+
const document = await workspace.openTextDocument({ language: 'markdown', content: uriOrContent });
15+
16+
uriOrContent = document.uri;
17+
}
18+
19+
void executeCoreCommand('vscode.openWith', uriOrContent, 'vscode.markdown.preview.editor', options);
20+
} catch (ex) {
21+
Logger.error(ex, 'showMarkdownPreview');
22+
debugger;
23+
}
24+
}

0 commit comments

Comments
 (0)