Skip to content

Commit c0924e2

Browse files
committed
open snippet on HackMD
1 parent b326512 commit c0924e2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/commands/snippet.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@ export function registerSnippetCommands(context: vscode.ExtensionContext) {
99
vscode.window.showInformationMessage('The code block is empty. Please select a range of text first.');
1010
return;
1111
}
12+
1213
const textRange = new vscode.Range(editor.selection.start.line, editor.selection.start.character, editor.selection.end.line, editor.selection.end.character);
1314
const text = vscode.window.activeTextEditor.document.getText(textRange);
1415
const snippet = `> \`${vscode.workspace.asRelativePath(editor.document.uri.fsPath)}\`\n\n\`\`\`${editor.document.languageId}=${editor.selection.start.line + 1}\n${text}\n\`\`\``;
15-
16-
await API.newNote(snippet);
16+
17+
const noteUrl = await API.newNote(snippet);
18+
const clicked = await vscode.window.showInformationMessage('New note Established!', ...['Copy URL to clip board', 'Open in browser']);
19+
if (clicked === 'Copy URL to clip board') {
20+
vscode.env.clipboard.writeText(noteUrl);
21+
} else if (clicked === 'Open in browser') {
22+
vscode.env.openExternal(vscode.Uri.parse(noteUrl));
23+
}
1724
}));
1825
}

0 commit comments

Comments
 (0)