mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
start draft
This commit is contained in:
@ -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": [
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user