start draft

This commit is contained in:
Peng Lyu
2019-05-17 18:36:36 -07:00
parent be77259d24
commit 78e140cbb0
2 changed files with 17 additions and 0 deletions

View File

@ -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": [

View File

@ -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);