diff --git a/comment-sample/package.json b/comment-sample/package.json index 752c358d..4bda1b02 100644 --- a/comment-sample/package.json +++ b/comment-sample/package.json @@ -56,6 +56,10 @@ { "command": "mywiki.cancelsaveNote", "title": "Cancel" + }, + { + "command": "mywiki.startDraft", + "title": "Start draft" } ], "menus": { @@ -96,6 +100,11 @@ "precondition": "commentIsEmpty", "group": "navigation", "when": "!commentThreadIsEmpty" + }, + { + "command": "mywiki.startDraft", + "precondition": "commentIsEmpty", + "group": "navigation" } ], "comment/title": [ diff --git a/comment-sample/src/extension.ts b/comment-sample/src/extension.ts index 65c54775..604cfd0f 100644 --- a/comment-sample/src/extension.ts +++ b/comment-sample/src/extension.ts @@ -6,6 +6,7 @@ let commentId = 1; class NoteComment implements vscode.Comment { id: number; + label: string | undefined; constructor( public body: string | vscode.MarkdownString, public mode: vscode.CommentMode, @@ -41,6 +42,13 @@ export function activate(context: vscode.ExtensionContext) { thread.comments = [...thread.comments, newComment]; })); + context.subscriptions.push(vscode.commands.registerCommand('mywiki.startDraft', (reply: vscode.CommentReply) => { + let thread = reply.thread; + let newComment = new NoteComment(reply.text, vscode.CommentMode.Preview, { name: 'vscode' }, thread); + newComment.label = 'pending'; + thread.comments = [...thread.comments, newComment]; + })); + context.subscriptions.push(vscode.commands.registerCommand('mywiki.deleteNoteComment', (comment: NoteComment) => { let thread = comment.parent; thread.comments = thread.comments.filter((cmt: NoteComment) => cmt.id !== comment.id);