diff --git a/comment-sample/package.json b/comment-sample/package.json index fb15cb16..73c1f4e0 100644 --- a/comment-sample/package.json +++ b/comment-sample/package.json @@ -22,6 +22,10 @@ "main": "./out/extension.js", "contributes": { "commands": [ + { + "command": "mywiki.createByCommand", + "title": "Create Note from Command" + }, { "command": "mywiki.createNote", "title": "Create Note", diff --git a/comment-sample/src/extension.ts b/comment-sample/src/extension.ts index 385b7f99..a4f44e39 100644 --- a/comment-sample/src/extension.ts +++ b/comment-sample/src/extension.ts @@ -33,6 +33,16 @@ export function activate(context: vscode.ExtensionContext) { } }; + context.subscriptions.push(vscode.commands.registerCommand('mywiki.createByCommand', () => { + const line = vscode.window.activeTextEditor?.selection.active.line; + if (line === undefined) { + return; + } + const thread = commentController.createCommentThread(vscode.window.activeTextEditor!.document.uri, new vscode.Range(line, 0, line, 0), [new NoteComment('', vscode.CommentMode.Editing, { name: 'vscode' })]); + thread.label = 'Test label'; + thread.collapsibleState = vscode.CommentThreadCollapsibleState.Expanded; + })); + context.subscriptions.push(vscode.commands.registerCommand('mywiki.createNote', (reply: vscode.CommentReply) => { replyNote(reply); }));