mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
update context key
This commit is contained in:
@ -40,8 +40,8 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
}));
|
||||
|
||||
context.subscriptions.push(vscode.commands.registerCommand('mywiki.startDraft', (reply: vscode.CommentReply) => {
|
||||
vscode.commands.executeCommand('setContext', 'inDraft', true);
|
||||
let thread = reply.thread;
|
||||
thread.contextValue = 'draft';
|
||||
let newComment = new NoteComment(reply.text, vscode.CommentMode.Preview, { name: 'vscode' }, thread);
|
||||
newComment.label = 'pending';
|
||||
thread.comments = [...thread.comments, newComment];
|
||||
@ -51,6 +51,7 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
vscode.commands.executeCommand('setContext', 'inDraft', false);
|
||||
|
||||
let thread = reply.thread;
|
||||
thread.collapsibleState = undefined;
|
||||
let newComment = new NoteComment(reply.text, vscode.CommentMode.Preview, { name: 'vscode' }, thread);
|
||||
thread.comments = [...thread.comments, newComment].map(comment => {
|
||||
comment.label = undefined;
|
||||
|
||||
40
comment-sample/src/typings/vscode.proposed.d.ts
vendored
40
comment-sample/src/typings/vscode.proposed.d.ts
vendored
@ -70,6 +70,26 @@ declare module 'vscode' {
|
||||
* The optional human-readable label describing the [Comment Thread](#CommentThread)
|
||||
*/
|
||||
label?: string;
|
||||
|
||||
/**
|
||||
* Context value of the comment thread. This can be used to contribute thread specific actions.
|
||||
* For example, a comment thread is given a context value as `editable`. When contributing actions to `comments/commentThread/title`
|
||||
* using `menus` extension point, you can specify context value for key `commentThread` in `when` expression like `commentThread == editable`.
|
||||
* ```
|
||||
* "contributes": {
|
||||
* "menus": {
|
||||
* "comments/commentThread/title": [
|
||||
* {
|
||||
* "command": "extension.deleteCommentThread",
|
||||
* "when": "commentThread == editable"
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* This will show action `extension.deleteCommentThread` only for comment threads with `contextValue` is `editable`.
|
||||
*/
|
||||
contextValue?: string;
|
||||
|
||||
/**
|
||||
* Dispose this comment thread.
|
||||
@ -115,6 +135,26 @@ declare module 'vscode' {
|
||||
* Label will be rendered next to authorName if exists.
|
||||
*/
|
||||
label?: string;
|
||||
|
||||
/**
|
||||
* Context value of the comment. This can be used to contribute comment specific actions.
|
||||
* For example, a comment is given a context value as `editable`. When contributing actions to `comments/comment/title`
|
||||
* using `menus` extension point, you can specify context value for key `comment` in `when` expression like `comment == editable`.
|
||||
* ```
|
||||
* "contributes": {
|
||||
* "menus": {
|
||||
* "comments/comment/title": [
|
||||
* {
|
||||
* "command": "extension.deleteComment",
|
||||
* "when": "comment == editable"
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* This will show action `extension.deleteComment` only for comments with `contextValue` is `editable`.
|
||||
*/
|
||||
contextValue?: string;
|
||||
}
|
||||
|
||||
export interface CommentReply {
|
||||
|
||||
Reference in New Issue
Block a user