mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
update comments namespace
This commit is contained in:
@ -85,40 +85,39 @@
|
||||
"when": "false"
|
||||
}
|
||||
],
|
||||
"commentThread/title": [
|
||||
"comments/commentThread/title": [
|
||||
{
|
||||
"command": "mywiki.deleteNote",
|
||||
"group": "navigation",
|
||||
"when": "!commentThreadIsEmpty"
|
||||
}
|
||||
],
|
||||
"commentThread/actions": [
|
||||
"comments/commentThread/actions": [
|
||||
{
|
||||
"command": "mywiki.createNote",
|
||||
"precondition": "commentIsEmpty",
|
||||
"group": "navigation",
|
||||
"precondition": "!commentIsEmpty",
|
||||
"when": "commentThreadIsEmpty"
|
||||
},
|
||||
{
|
||||
"command": "mywiki.replyNote",
|
||||
"precondition": "commentIsEmpty",
|
||||
"group": "navigation",
|
||||
"precondition": "!commentIsEmpty",
|
||||
"when": "!commentThreadIsEmpty"
|
||||
},
|
||||
{
|
||||
"command": "mywiki.startDraft",
|
||||
"precondition": "commentIsEmpty",
|
||||
"group": "navigation",
|
||||
"precondition": "!commentIsEmpty",
|
||||
"when": "!inDraft"
|
||||
},
|
||||
{
|
||||
"command": "mywiki.finishDraft",
|
||||
"precondition": "commentIsEmpty",
|
||||
"group": "navigation",
|
||||
"when": "inDraft"
|
||||
}
|
||||
],
|
||||
"comment/title": [
|
||||
"comments/comment/title": [
|
||||
{
|
||||
"command": "mywiki.editNote",
|
||||
"group": "group@1"
|
||||
@ -128,7 +127,7 @@
|
||||
"group": "group@2"
|
||||
}
|
||||
],
|
||||
"comment/actions": [
|
||||
"comments/comment/actions": [
|
||||
{
|
||||
"command": "mywiki.cancelsaveNote",
|
||||
"group": "group@1"
|
||||
|
||||
@ -19,7 +19,7 @@ class NoteComment implements vscode.Comment {
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
// A `CommentController` is able to provide comments for documents.
|
||||
const commentController = vscode.comment.createCommentController('comment-sample', 'Comment API Sample');
|
||||
const commentController = vscode.comments.createCommentController('comment-sample', 'Comment API Sample');
|
||||
context.subscriptions.push(commentController);
|
||||
vscode.commands.executeCommand('setContext', 'inDraft', false);
|
||||
|
||||
@ -30,15 +30,15 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
return [new vscode.Range(0, 0, lineCount - 1, 0)];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('mywiki.createNote', (reply: vscode.CommentReply) => {
|
||||
replyNote(reply);
|
||||
}));
|
||||
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('mywiki.replyNote', (reply: vscode.CommentReply) => {
|
||||
replyNote(reply);
|
||||
}));
|
||||
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('mywiki.startDraft', (reply: vscode.CommentReply) => {
|
||||
vscode.commands.executeCommand('setContext', 'inDraft', true);
|
||||
let thread = reply.thread;
|
||||
@ -46,7 +46,7 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
newComment.label = 'pending';
|
||||
thread.comments = [...thread.comments, newComment];
|
||||
}));
|
||||
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('mywiki.finishDraft', (reply: vscode.CommentReply) => {
|
||||
vscode.commands.executeCommand('setContext', 'inDraft', false);
|
||||
|
||||
@ -57,11 +57,11 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
return comment;
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
if (thread.comments.length === 0) {
|
||||
thread.dispose();
|
||||
}
|
||||
@ -70,33 +70,33 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
context.subscriptions.push(vscode.commands.registerCommand('mywiki.deleteNote', (thread: vscode.CommentThread) => {
|
||||
thread.dispose();
|
||||
}));
|
||||
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('mywiki.cancelsaveNote', (comment: NoteComment) => {
|
||||
comment.parent.comments = comment.parent.comments.map((cmt: NoteComment) => {
|
||||
if (cmt.id === comment.id) {
|
||||
if (cmt.id === comment.id) {
|
||||
cmt.mode = vscode.CommentMode.Preview;
|
||||
}
|
||||
|
||||
|
||||
return cmt;
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('mywiki.saveNote', (comment: NoteComment) => {
|
||||
comment.parent.comments = comment.parent.comments.map((cmt: NoteComment) => {
|
||||
if (cmt.id === comment.id) {
|
||||
if (cmt.id === comment.id) {
|
||||
cmt.mode = vscode.CommentMode.Preview;
|
||||
}
|
||||
|
||||
|
||||
return cmt;
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('mywiki.editNote', (comment: NoteComment) => {
|
||||
comment.parent.comments = comment.parent.comments.map((cmt: NoteComment) => {
|
||||
if (cmt.id === comment.id) {
|
||||
if (cmt.id === comment.id) {
|
||||
cmt.mode = vscode.CommentMode.Editing;
|
||||
}
|
||||
|
||||
|
||||
return cmt;
|
||||
});
|
||||
}));
|
||||
|
||||
@ -175,7 +175,7 @@ declare module 'vscode' {
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
namespace comment {
|
||||
namespace comments {
|
||||
/**
|
||||
* Creates a new [comment controller](#CommentController) instance.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user