Skip to content

Commit 3f053dd

Browse files
committed
Create active editor content to HackMD
1 parent 1293699 commit 3f053dd

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"onView:mdTreeItems",
1717
"onCommand:HackMD.login",
1818
"onCommand:HackMD.logout",
19-
"onCommand:note.newNote"
19+
"onCommand:HackMD.createActiveEditorContentToHackMD"
2020
],
2121
"license": "MIT",
2222
"homepage": "https://github.com/hackmdio/vscode-hackmd/blob/master/README.md",
@@ -90,8 +90,8 @@
9090
"icon": "src/icon/education.svg"
9191
},
9292
{
93-
"command": "note.newNote",
94-
"title": "New note"
93+
"command": "HackMD.createActiveEditorContentToHackMD",
94+
"title": "HackMD: Create active editor Content to HackMD"
9595
}
9696
],
9797
"menus": {

src/commands/note.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,13 @@ import { checkLogin } from './../utils';
44
const API = new apiClient.default();
55

66
export async function registerNoteCommands(context: vscode.ExtensionContext) {
7-
context.subscriptions.push(vscode.commands.registerCommand('note.newNote', async () => {
7+
context.subscriptions.push(vscode.commands.registerCommand('HackMD.createActiveEditorContentToHackMD', async () => {
88
if (!(await checkLogin())) {
99
vscode.window.showInformationMessage('Please login first.');
1010
return;
1111
}
12-
const mdText = await vscode.window.showInputBox({
13-
ignoreFocusOut: true,
14-
password: false,
15-
placeHolder: 'MarkDown content',
16-
prompt: 'Please write down your note text',
17-
});
1812

13+
const mdText = vscode.window.activeTextEditor.document.getText();
1914
const noteUrl = await API.newNote(mdText);
2015
const clicked = await vscode.window.showInformationMessage('New note Established!', ...['Copy URL to clip board', 'Open in browser']);
2116
if (clicked === 'Copy URL to clip board') {

0 commit comments

Comments
 (0)