diff --git a/CHANGELOG.md b/CHANGELOG.md index dbe3700..fec9128 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## v0.4.0 (11/20/21) + +- Added `Copy File to Gist` command to the notebook editor toolbar +- Changed the `Showcase` view to be hidden by default + ## v0.3.0 (07/06/21) - Fixed a bug with updating notebook files diff --git a/package.json b/package.json index 87d47cf..018721f 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "GistPad", "description": "Manage your code snippets and developer notes using GitHub Gists and repositories.", "publisher": "vsls-contrib", - "version": "0.3.0", + "version": "0.4.0", "extensionKind": [ "ui", "workspace" @@ -127,7 +127,8 @@ }, { "command": "gistpad.addFileToGist", - "title": "Copy File to Gist" + "title": "Copy File to Gist", + "icon": "$(github)" }, { "command": "gistpad.addGistComment", @@ -1407,6 +1408,11 @@ "group": "inline", "when": "commentController == gistpad:repo && commentThreadIsEmpty && gistpad:state == SignedIn" } + ], + "notebook/toolbar": [ + { + "command": "gistpad.addFileToGist" + } ] }, "viewsContainers": { @@ -1431,7 +1437,7 @@ { "id": "gistpad.showcase", "name": "Showcase", - "visibility": "collapsed", + "visibility": "hidden", "when": "gistpad:state == SignedIn" } ] diff --git a/src/commands/editor.ts b/src/commands/editor.ts index fb3acd0..c9c18a1 100644 --- a/src/commands/editor.ts +++ b/src/commands/editor.ts @@ -95,11 +95,16 @@ export async function promptForGistSelection(files: GistFile[]) { } export function registerEditorCommands(context: ExtensionContext) { + // This command can be called from four different contexts: + // 1) Right-clicking a file in the "Explorer" tree (Uri) + // 2) Right-clicking the editor tab of a file (Uri) + // 3) Right-clicking a file in the "Gists" tree (GistFileNode) + // 4) From the toolbar of the notebook editor context.subscriptions.push( commands.registerCommand( `${EXTENSION_NAME}.addFileToGist`, async ( - targetNode: GistFileNode | Uri, + targetNode: GistFileNode | Uri | { notebookEditor: { notebookUri: Uri }}, multiSelectNodes?: GistFileNode[] | Uri[] ) => { await ensureAuthenticated(); @@ -124,12 +129,14 @@ export function registerEditorCommands(context: ExtensionContext) { ) }); } else { + const uri = node instanceof Uri ? node : node.notebookEditor.notebookUri; + // The command is being called as a response to // right-clicking a file node in the explorer // and/or right-clicking the editor tab files.push({ - filename: path.basename(node.path), - content: byteArrayToString(await workspace.fs.readFile(node)) + filename: path.basename(uri.path), + content: byteArrayToString(await workspace.fs.readFile(uri)) }); } }