Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions extension.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const vscode = require('vscode');

const {newNote, newNoteInWorkspace} = require('./src/newNote');
const {deleteNote} = require('./src/deleteNote');
const listNotes = require('./src/listNotes');
const listTags = require('./src/listTags')
const setupNotes = require('./src/setupNotes');
Expand All @@ -27,6 +28,10 @@ function activate(context) {
let newNoteInWorkspaceDisposable = vscode.commands.registerCommand('vsnotes.newNoteInWorkspace', newNoteInWorkspace);
context.subscriptions.push(newNoteInWorkspaceDisposable);

// Delete a new note
let deleteNoteDisposable = vscode.commands.registerCommand('vsnotes.deleteNote', deleteNote);
context.subscriptions.push(deleteNoteDisposable);

// Open a note
let listNotesDisposable = vscode.commands.registerCommand('vsnotes.listNotes', listNotes);
context.subscriptions.push(listNotesDisposable);
Expand Down
22 changes: 21 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@
"description": "Number of recent files to show when running command `List Notes`."
},
"vsnotes.noteTitleConvertSpaces": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"default": "_",
"description": "Automatically convert blank spaces in title to character. To disable set to `null`."
},
Expand Down Expand Up @@ -236,6 +239,10 @@
"light": "./media/light/sync.svg",
"dark": "./media/dark/sync.svg"
}
},
{
"command": "vsnotes.deleteNote",
"title": "Delete Note"
}
],
"keybindings": [
Expand Down Expand Up @@ -275,6 +282,19 @@
"when": "view == vsnotes",
"group": "navigation"
}
],
"commandPalette": [
{
"command": "vsnotes.deleteNote",
"when": "false"
}
],
"view/item/context": [
{
"command": "vsnotes.deleteNote",
"group": "7_modification",
"when": "viewItem == note"
}
]
}
},
Expand Down
15 changes: 15 additions & 0 deletions src/deleteNote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

const fs = require('fs-extra');
const vscode = require('vscode');

function deleteNote(note) {
fs.remove(note.path, err => {
if(err) return console.error(err);
console.log('successfully remove note');
vscode.commands.executeCommand('vsnotes.refreshVSNotesView');
});
}

module.exports = {
deleteNote
}
1 change: 1 addition & 0 deletions src/treeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class VSNotesTreeView {
light: path.join(__filename, '..', '..', 'media', 'light', 'file.svg'),
dark: path.join(__filename, '..', '..', 'media', 'dark', 'file.svg')
};
fileTreeItem.contextValue="note";
}
return fileTreeItem;
}
Expand Down