├── resources ├── icon.png ├── dark │ ├── folder-open.svg │ ├── add.svg │ ├── tag.svg │ ├── note.svg │ ├── folder.svg │ ├── refresh.svg │ ├── delete.svg │ ├── category.svg │ ├── rename.svg │ └── settings.svg ├── light │ ├── folder-open.svg │ ├── add.svg │ ├── tag.svg │ ├── note.svg │ ├── folder.svg │ ├── refresh.svg │ ├── delete.svg │ ├── category.svg │ ├── rename.svg │ └── settings.svg ├── notes-light.svg └── notes-dark.svg ├── screenshots └── screenshot.png ├── src ├── types │ ├── mkdirp.d.ts │ └── rimraf.d.ts ├── test │ ├── suite │ │ ├── extension.test.ts │ │ └── index.ts │ └── runTest.ts ├── note.ts ├── notesViewProvider.ts ├── viewProvider.ts └── extension.ts ├── .gitignore ├── .vscodeignore ├── .eslintrc.json ├── tsconfig.json ├── webpack.config.js ├── CHANGELOG.md ├── README.md ├── package.json └── LICENSE /resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dionmunk/vscode-notes/HEAD/resources/icon.png -------------------------------------------------------------------------------- /screenshots/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dionmunk/vscode-notes/HEAD/screenshots/screenshot.png -------------------------------------------------------------------------------- /src/types/mkdirp.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'mkdirp' { 2 | function mkdirp(dir: string): Promise; 3 | export = mkdirp; 4 | } 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .notes 3 | .vscode 4 | .vscode-test 5 | _source 6 | dist 7 | node_modules 8 | notes 9 | out 10 | NOTES.md 11 | **/*.vsix -------------------------------------------------------------------------------- /src/types/rimraf.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'rimraf' { 2 | function rimraf(path: string, callback: (error: Error | null) => void): void; 3 | export = rimraf; 4 | } 5 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | _source/** 4 | notes/** 5 | out/** 6 | src/** 7 | .gitignore 8 | NOTES.md 9 | webpack.config.js 10 | **/*.map 11 | **/*.js.map 12 | **/*.ts 13 | **/.eslintrc.json 14 | **/tsconfig.json -------------------------------------------------------------------------------- /resources/dark/folder-open.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/light/folder-open.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "parserOptions": { 5 | "ecmaVersion": 6, 6 | "sourceType": "module" 7 | }, 8 | "plugins": [ 9 | "@typescript-eslint" 10 | ], 11 | "rules": { 12 | "@typescript-eslint/class-name-casing": "warn", 13 | "@typescript-eslint/semi": "warn", 14 | "curly": "warn", 15 | "eqeqeq": "warn", 16 | "no-throw-literal": "warn", 17 | "semi": "off" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/suite/extension.test.ts: -------------------------------------------------------------------------------- 1 | import * as assert from 'assert'; 2 | 3 | // You can import and use all API from the 'vscode' module 4 | // as well as import your extension to test it 5 | import * as vscode from 'vscode'; 6 | // import * as myExtension from '../extension'; 7 | 8 | suite('Extension Test Suite', () => { 9 | vscode.window.showInformationMessage('Start all tests.'); 10 | 11 | test('Sample test', () => { 12 | assert.equal(-1, [1, 2, 3].indexOf(5)); 13 | assert.equal(-1, [1, 2, 3].indexOf(0)); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /resources/dark/add.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /resources/light/add.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /resources/dark/tag.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /resources/light/tag.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /resources/dark/note.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /resources/light/note.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /resources/dark/folder.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/light/folder.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/dark/refresh.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /resources/light/refresh.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /resources/dark/delete.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /resources/light/delete.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/test/runTest.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | 3 | import { runTests } from 'vscode-test'; 4 | 5 | async function main() { 6 | try { 7 | // The folder containing the Extension Manifest package.json 8 | // Passed to `--extensionDevelopmentPath` 9 | const extensionDevelopmentPath = path.resolve(__dirname, '../../'); 10 | 11 | // The path to test runner 12 | // Passed to --extensionTestsPath 13 | const extensionTestsPath = path.resolve(__dirname, './suite/index'); 14 | 15 | // Download VS Code, unzip it and run the integration test 16 | await runTests({ extensionDevelopmentPath, extensionTestsPath }); 17 | } catch (err) { 18 | console.error('Failed to run tests'); 19 | process.exit(1); 20 | } 21 | } 22 | 23 | main(); 24 | -------------------------------------------------------------------------------- /resources/dark/category.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /resources/light/category.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "outDir": "out", 6 | "lib": [ 7 | "es6" 8 | ], 9 | "sourceMap": true, 10 | "rootDir": "src", 11 | "strict": true, /* enable all strict type-checking options */ 12 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules */ 13 | "typeRoots": [ 14 | "./node_modules/@types", 15 | "./src/types" 16 | ], 17 | /* Additional Checks */ 18 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 19 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 20 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 21 | }, 22 | "exclude": [ 23 | "node_modules", 24 | ".vscode-test" 25 | ] 26 | } -------------------------------------------------------------------------------- /resources/dark/rename.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /resources/light/rename.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /resources/dark/settings.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /resources/light/settings.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /src/test/suite/index.ts: -------------------------------------------------------------------------------- 1 | import * as path from 'path'; 2 | import Mocha from 'mocha'; 3 | import { glob } from 'glob'; 4 | 5 | export function run(): Promise { 6 | // Create the mocha test 7 | const mocha = new Mocha({ 8 | ui: 'tdd', 9 | color: true 10 | }); 11 | 12 | const testsRoot = path.resolve(__dirname, '..'); 13 | 14 | return new Promise(async (resolve, reject) => { 15 | try { 16 | // Use the glob promise API 17 | const files = await glob('**/**.test.js', { cwd: testsRoot }); 18 | 19 | // Add files to the test suite 20 | files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); 21 | 22 | // Run the mocha test 23 | mocha.run((failures: number) => { 24 | if (failures > 0) { 25 | reject(new Error(`${failures} tests failed.`)); 26 | } else { 27 | resolve(); 28 | } 29 | }); 30 | } catch (err) { 31 | console.error(err); 32 | reject(err); 33 | } 34 | }); 35 | } 36 | -------------------------------------------------------------------------------- /resources/notes-light.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /resources/notes-dark.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 13 | 14 | -------------------------------------------------------------------------------- /src/note.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import * as path from 'path'; 3 | 4 | export class Note extends vscode.TreeItem { 5 | public readonly isFolder: boolean; 6 | public readonly fullPath: string; 7 | 8 | constructor( 9 | public readonly name: string, 10 | public readonly location: string, 11 | public readonly category: string, 12 | public readonly tags: string, 13 | public readonly isDirectory: boolean = false, 14 | public readonly command?: vscode.Command 15 | ) { 16 | super(name, isDirectory ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.None); 17 | this.name = name; 18 | this.location = location; 19 | this.category = category; 20 | this.tags = tags; 21 | this.isFolder = isDirectory; 22 | this.fullPath = path.join(location, name); 23 | 24 | // Set appropriate icon based on whether this is a folder or file 25 | if (isDirectory) { 26 | // Use VS Code's built-in folder icons 27 | this.iconPath = new vscode.ThemeIcon('folder'); 28 | } else { 29 | // Use VS Code's built-in file type icons based on extension 30 | this.iconPath = vscode.ThemeIcon.File; 31 | } 32 | 33 | // Set contextValue based on whether this is a folder or note 34 | this.contextValue = isDirectory ? 'folder' : 'note'; 35 | } 36 | 37 | tooltip = this.name; 38 | } 39 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | //@ts-check 2 | 3 | 'use strict'; 4 | 5 | const path = require('path'); 6 | 7 | /**@type {import('webpack').Configuration}*/ 8 | const config = { 9 | target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/ 10 | node: false, // fixes weird issues with locations in node (__filename, __dirname) 11 | entry: './src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/ 12 | output: { 13 | // the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/ 14 | path: path.resolve(__dirname, 'dist'), 15 | filename: 'extension.js', 16 | libraryTarget: 'commonjs2', 17 | devtoolModuleFilenameTemplate: '../[resource-path]' 18 | }, 19 | devtool: 'source-map', 20 | externals: { 21 | vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/ 22 | }, 23 | resolve: { 24 | // support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader 25 | extensions: ['.ts', '.js'] 26 | }, 27 | module: { 28 | rules: [ 29 | { 30 | test: /\.ts$/, 31 | exclude: /node_modules/, 32 | use: [ 33 | { 34 | loader: 'ts-loader' 35 | } 36 | ] 37 | } 38 | ] 39 | } 40 | }; 41 | module.exports = config; -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "vscode-notes" extension will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [Unreleased] 9 | 10 | ## [2.0.0] - 2025-03-26 11 | 12 | ### Added 13 | 14 | * directory support 15 | 16 | ## changed 17 | 18 | * note filetype support 19 | * setup functionality 20 | * icons 21 | 22 | ## [1.2.1] - 2023-12-28 23 | 24 | ### Added 25 | 26 | * new sidebar icon 27 | 28 | ## [1.2.0] - 2023-12-27 29 | 30 | ### Added 31 | 32 | * new Notes.notesDefaultNotesExtension setting to set extension of new notes. The default is `md`. 33 | * new Notes.notesExtensions setting to allow Notes to detect different file types when generating a list of notes. Must be a comma separated list of file extensions eg: `md,markdown,txt` etc. The default is `md,markdown,txt`. 34 | 35 | ### Fixed 36 | 37 | * Updated packages and requirements to latest versions. 38 | 39 | ## [1.1.0] - 2020-04-04 40 | 41 | ### Added 42 | 43 | * activity bar icon 44 | * view list of notes in selected location 45 | * icon to create a new note 46 | * rename a note 47 | * delete a note 48 | 49 | ### Changed 50 | 51 | * build extension using webpack to minify 52 | 53 | ## [1.0.0] - 2020-03-26 54 | 55 | ### Added 56 | 57 | * set notes location 58 | * create a new note 59 | * list new notes 60 | 61 | [Unreleased]: https://github.com/dionmunk/vscode-notes/compare/v2.0.0...HEAD 62 | [2.0.0]: https://github.com/dionmunk/vscode-notes/compare/v1.2.1...v2.0.0 63 | [1.2.1]: https://github.com/dionmunk/vscode-notes/compare/v1.2.0...v1.2.1 64 | [1.2.0]: https://github.com/dionmunk/vscode-notes/compare/v1.1.0...v1.2.0 65 | [1.1.0]: https://github.com/dionmunk/vscode-notes/compare/v1.0.0...v1.1.0 66 | [1.0.0]: https://github.com/dionmunk/vscode-notes/compare/v1.0.0 67 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Notes 2 | 3 | [![Creative Commons](https://flat.badgen.net/badge/license/CC-BY-NC-4.0/orange)](https://creativecommons.org/licenses/by-nc/4.0/) 4 | [![GitHub](https://flat.badgen.net/github/release/dionmunk/vscode-notes/)](https://github.com/dionmunk/vscode-notes/releases) 5 | [![Visual Studio Marketplace](https://vsmarketplacebadges.dev/installs/dionmunk.vscode-notes.png?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=dionmunk.vscode-notes) 6 | 7 | Notes is a Markdown focused notes extension for Visual Studio Code that takes inspiration from Notational Velocity and nvAlt. 8 | 9 | ![Notes Demo](/screenshots/screenshot.png?raw=true "Notes Demo") 10 | 11 | ## Features 12 | 13 | Notes are stored in a single location (directory) located anywhere on your system you'd like. This allows you to store notes locally or inside a cloud service like Dropbox, iCloud Drive, Google Drive, OneDrive, etc. Notes are written in Markdown and are stored as **.md** by default, but you can change this to whatever you want. It's recommended to name your notes with a file extension, like **.md**, or VS Code won't know how to render your note correctly. 14 | 15 | The extension can be accessed using the Notes icon that is placed in the Activity Bar, or in the Command Pallet (CMD+Shift+P or CTRL+Shift+P) by typing `Notes`. 16 | 17 | * quickly create new notes by using the `Alt+N` shortcut, or by click on the `+` icon at the top when you are in Notes. 18 | * quickly access your list of notes by using the `Alt+L` shortcut to bring up a searchable list at the top of VSCode. 19 | * hovering over a note inside Notes displays two icons, one allows you to rename a note and the other allows you to delete a note. *Deleting a note is permanent, so be careful.* 20 | 21 | ## Getting Started 22 | 23 | Notes will prompt you for a storage location the first time you access the extension from the Activity Bar or through the Command Pallet. If you would like to change the storage location, later on, you can access the Notes extension settings by clicking on the gear icon in Notes or from the Command Pallet. After you've selected a storage location, you can access your notes from the Notes icon in the Activity Bar, or through the Command Pallet. 24 | 25 | ## Extension Settings 26 | 27 | This extension contributes the following settings: 28 | 29 | * `Notes.notesLocation`: location where notes are stored 30 | * `Notes.notesDefaultNotesExtension`: extension used for new notes 31 | * `Notes.notesExtensions`: list of extensions recognized as notes or '*' for all extensions 32 | 33 | ## Future Plans 34 | 35 | * custom Notes editor with shortcuts for common Markdown functions (bold, italic, link, code block, etc.) 36 | * option to have an automatic Markdown preview pop up when you start editing a note 37 | * search notes in the Notes view using note name and contents 38 | * allow for front matter in Notes like tags and categories (with possible tree structure based on tags and categories) 39 | * allow for multiple Notes' storage locations and make them switchable 40 | 41 | ## License 42 | 43 | This work is licensed under a [Creative Commons Attribution-NonCommercial 4.0 International License](https://creativecommons.org/licenses/by-nc/4.0/). 44 | -------------------------------------------------------------------------------- /src/notesViewProvider.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import * as fs from 'fs'; 3 | import * as gl from 'glob'; 4 | import * as path from 'path'; 5 | import { Note } from './note'; 6 | 7 | export class NotesViewProvider implements vscode.TreeDataProvider { 8 | 9 | private _onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter(); 10 | readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event; 11 | private folderMap: Map = new Map(); 12 | 13 | // constructor for NotesViewProvider 14 | constructor( 15 | private notesLocation: string, 16 | private notesExtensions: string) { 17 | }; 18 | 19 | // initialize NotesViewProvider 20 | public init(): NotesViewProvider { 21 | this.refresh(); 22 | return this; 23 | } 24 | 25 | // refresh the tree view 26 | refresh(): void { 27 | this._onDidChangeTreeData.fire(undefined); 28 | } 29 | 30 | // get the parent of a note 31 | getTreeItem(note: Note): vscode.TreeItem { 32 | return note; 33 | } 34 | 35 | // get the children of a note 36 | getChildren(note?: Note): Thenable { 37 | // if there is no notes location return an empty list 38 | if (!this.notesLocation) { 39 | return Promise.resolve([]); 40 | } 41 | 42 | // if there is a parent note and it's a folder 43 | if (note && note.isFolder) { 44 | // Return the children of this folder 45 | return Promise.resolve(this.getNotes(note.fullPath, this.notesExtensions)); 46 | } 47 | // if there is a note but it's not a folder, return empty list 48 | else if (note) { 49 | return Promise.resolve([]); 50 | } 51 | // else return the list of notes at the root level 52 | else { 53 | return Promise.resolve(this.getNotes(this.notesLocation, this.notesExtensions)); 54 | } 55 | } 56 | 57 | // get the notes in the notes location 58 | getNotes(notesLocation: string, notesExtensions: string): Note[] { 59 | // if the notes location exists 60 | if (this.pathExists(notesLocation)) { 61 | const result: Note[] = []; 62 | 63 | // First, add all folders 64 | try { 65 | const items = fs.readdirSync(notesLocation, { withFileTypes: true }); 66 | 67 | // Add folders first 68 | for (const item of items) { 69 | if (item.isDirectory()) { 70 | const folderPath = path.join(notesLocation, item.name); 71 | const folderNote = new Note( 72 | item.name, 73 | notesLocation, 74 | '', // category 75 | '', // tags 76 | true // isDirectory 77 | ); 78 | result.push(folderNote); 79 | } 80 | } 81 | 82 | // Then add notes 83 | const listOfNotes = (note: string): Note => { 84 | // return a note with the given note name, notes location, empty category, empty tags, and the command to open the note 85 | return new Note( 86 | path.basename(note), 87 | notesLocation, 88 | '', // category 89 | '', // tags 90 | false, // isDirectory 91 | { 92 | command: 'Notes.openNote', 93 | title: '', 94 | arguments: [path.join(notesLocation, note)] 95 | }); 96 | }; 97 | 98 | // get the list of notes in the notes location 99 | let notes; 100 | if (notesExtensions === '*') { 101 | // If '*' is specified, get all files (excluding directories) 102 | notes = gl.sync('*', { cwd: notesLocation, nodir: true, nocase: true }).map(listOfNotes); 103 | } else { 104 | // Otherwise, filter by the specified extensions 105 | notes = gl.sync(`*.{${notesExtensions}}`, { cwd: notesLocation, nodir: true, nocase: true }).map(listOfNotes); 106 | } 107 | result.push(...notes); 108 | } catch (err) { 109 | console.error('Error reading directory:', err); 110 | } 111 | 112 | // Sort: folders first, then notes alphabetically 113 | result.sort((a, b) => { 114 | if (a.isFolder && !b.isFolder) { 115 | return -1; 116 | } 117 | if (!a.isFolder && b.isFolder) { 118 | return 1; 119 | } 120 | return a.name.localeCompare(b.name); 121 | }); 122 | 123 | return result; 124 | } 125 | // else if the notes location does not exist 126 | else { 127 | // return an empty list 128 | return []; 129 | } 130 | } 131 | 132 | // check if a path exists 133 | private pathExists(p: string): boolean { 134 | // try to access the given location 135 | try { 136 | fs.accessSync(p); 137 | // return false if location does not exist 138 | } catch (err) { 139 | return false; 140 | } 141 | // return true if location exists 142 | return true; 143 | } 144 | 145 | } 146 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode-notes", 3 | "displayName": "Notes", 4 | "description": "Notes is a Markdown focused notes extension for Visual Studio Code that takes inspiration from Notational Velocity and nvAlt.", 5 | "version": "2.0.0", 6 | "publisher": "dionmunk", 7 | "license": "CC-BY-NC-4.0", 8 | "author": { 9 | "name": "Dion Munk", 10 | "url": "https://github.com/dionmunk" 11 | }, 12 | "keywords": [ 13 | "notes", 14 | "notational velocity", 15 | "nvalt" 16 | ], 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/dionmunk/vscode-notes" 20 | }, 21 | "homepage": "https://github.com/dionmunk/vscode-notes#readme", 22 | "bugs": { 23 | "url": "https://github.com/dionmunk/vscode-notes/issues" 24 | }, 25 | "icon": "resources/icon.png", 26 | "engines": { 27 | "vscode": "^1.87.0" 28 | }, 29 | "categories": [ 30 | "Other" 31 | ], 32 | "activationEvents": [], 33 | "main": "./dist/extension", 34 | "contributes": { 35 | "configuration": { 36 | "title": "Notes", 37 | "properties": { 38 | "notes.notesLocation": { 39 | "type": "string", 40 | "default": "", 41 | "description": "Storage location for notes." 42 | }, 43 | "notes.notesDefaultNoteExtension": { 44 | "type": "string", 45 | "default": "md", 46 | "description": "The default extension to use for new notes. (do not include the dot)" 47 | }, 48 | "notes.notesExtensions": { 49 | "type": "string", 50 | "default": "*", 51 | "description": "A comma separated list of allowed extensions for notes. Use '*' (asterisk) to allow all file types. (do not include the dot or spaces)" 52 | } 53 | } 54 | }, 55 | "commands": [ 56 | { 57 | "command": "Notes.deleteNote", 58 | "title": "Delete Note", 59 | "icon": { 60 | "light": "resources/light/delete.svg", 61 | "dark": "resources/dark/delete.svg" 62 | } 63 | }, 64 | { 65 | "command": "Notes.deleteFolder", 66 | "title": "Delete Folder", 67 | "icon": { 68 | "light": "resources/light/delete.svg", 69 | "dark": "resources/dark/delete.svg" 70 | } 71 | }, 72 | { 73 | "command": "Notes.listNotes", 74 | "title": "List Notes", 75 | "category": "Notes" 76 | }, 77 | { 78 | "command": "Notes.newNote", 79 | "title": "New Note", 80 | "category": "Notes", 81 | "icon": "$(new-file)" 82 | }, 83 | { 84 | "command": "Notes.newFolder", 85 | "title": "New Folder", 86 | "category": "Notes", 87 | "icon": "$(new-folder)" 88 | }, 89 | { 90 | "command": "Notes.refreshNotes", 91 | "title": "Refresh Notes", 92 | "category": "Notes", 93 | "icon": "$(refresh)" 94 | }, 95 | { 96 | "command": "Notes.renameNote", 97 | "title": "Rename Note", 98 | "icon": { 99 | "light": "resources/light/rename.svg", 100 | "dark": "resources/dark/rename.svg" 101 | } 102 | }, 103 | { 104 | "command": "Notes.renameFolder", 105 | "title": "Rename Folder", 106 | "icon": { 107 | "light": "resources/light/rename.svg", 108 | "dark": "resources/dark/rename.svg" 109 | } 110 | }, 111 | { 112 | "command": "Notes.setupNotes", 113 | "title": "Settings", 114 | "category": "Notes", 115 | "icon": "$(gear)" 116 | } 117 | ], 118 | "keybindings": [ 119 | { 120 | "command": "Notes.listNotes", 121 | "key": "alt+l", 122 | "mac": "alt+l" 123 | }, 124 | { 125 | "command": "Notes.newNote", 126 | "key": "alt+n", 127 | "mac": "alt+n" 128 | } 129 | ], 130 | "menus": { 131 | "view/title": [ 132 | { 133 | "command": "Notes.newNote", 134 | "when": "view == notes", 135 | "group": "navigation@1" 136 | }, 137 | { 138 | "command": "Notes.newFolder", 139 | "when": "view == notes", 140 | "group": "navigation@2" 141 | }, 142 | { 143 | "command": "Notes.refreshNotes", 144 | "when": "view == notes", 145 | "group": "navigation@3" 146 | }, 147 | { 148 | "command": "Notes.setupNotes", 149 | "when": "view == notes", 150 | "group": "navigation@4" 151 | } 152 | ], 153 | "view/item/context": [ 154 | { 155 | "command": "Notes.renameNote", 156 | "when": "view == notes && viewItem == note", 157 | "group": "1_modification@1" 158 | }, 159 | { 160 | "command": "Notes.deleteNote", 161 | "when": "view == notes && viewItem == note", 162 | "group": "1_modification@2" 163 | }, 164 | { 165 | "command": "Notes.renameFolder", 166 | "when": "view == notes && viewItem == folder", 167 | "group": "1_modification@1" 168 | }, 169 | { 170 | "command": "Notes.deleteFolder", 171 | "when": "view == notes && viewItem == folder", 172 | "group": "1_modification@2" 173 | }, 174 | { 175 | "command": "Notes.newNote", 176 | "when": "view == notes && viewItem == folder", 177 | "group": "2_workspace@1" 178 | }, 179 | { 180 | "command": "Notes.newFolder", 181 | "when": "view == notes && viewItem == folder", 182 | "group": "2_workspace@2" 183 | }, 184 | { 185 | "command": "Notes.newNote", 186 | "when": "view == notes && !viewItem", 187 | "group": "navigation@1" 188 | }, 189 | { 190 | "command": "Notes.newFolder", 191 | "when": "view == notes && !viewItem", 192 | "group": "navigation@2" 193 | }, 194 | { 195 | "command": "Notes.refreshNotes", 196 | "when": "view == notes && !viewItem", 197 | "group": "navigation@3" 198 | } 199 | ] 200 | }, 201 | "viewsContainers": { 202 | "activitybar": [ 203 | { 204 | "id": "vscode-notes", 205 | "title": "Notes", 206 | "icon": "resources/notes-light.svg" 207 | } 208 | ] 209 | }, 210 | "views": { 211 | "vscode-notes": [ 212 | { 213 | "id": "notes", 214 | "name": "Notes" 215 | } 216 | ] 217 | }, 218 | "viewsWelcome": [ 219 | { 220 | "view": "notes", 221 | "contents": "To get started, you need to select a location to store your notes.\n[Select Location](command:Notes.setupNotes)" 222 | } 223 | ] 224 | }, 225 | "scripts": { 226 | "vscode:prepublish": "NODE_OPTIONS=--openssl-legacy-provider webpack --mode production", 227 | "compile": "tsc -p ./", 228 | "lint": "eslint src --ext ts", 229 | "watch": "tsc -watch -p ./", 230 | "pretest": "npm run compile && npm run lint", 231 | "test": "node ./out/test/runTest.js", 232 | "webpack": "NODE_OPTIONS=--openssl-legacy-provider webpack --mode development", 233 | "webpack-dev": "NODE_OPTIONS=--openssl-legacy-provider webpack --mode development --watch", 234 | "test-compile": "tsc -p ./" 235 | }, 236 | "devDependencies": { 237 | "@types/glob": "^8.1.0", 238 | "@types/mkdirp": "^2.0.0", 239 | "@types/mocha": "^10.0.6", 240 | "@types/node": "^20.11.0", 241 | "@types/rimraf": "^4.0.5", 242 | "@types/vscode": "^1.87.0", 243 | "@typescript-eslint/eslint-plugin": "^7.0.0", 244 | "@typescript-eslint/parser": "^7.0.0", 245 | "eslint": "^8.56.0", 246 | "glob": "^10.3.10", 247 | "mocha": "^10.2.0", 248 | "ts-loader": "^9.5.1", 249 | "typescript": "^5.3.3", 250 | "vscode-test": "^1.6.1", 251 | "webpack": "^5.89.0", 252 | "webpack-cli": "^5.1.4" 253 | }, 254 | "dependencies": { 255 | "vscode-uri": "^3.0.8" 256 | } 257 | } -------------------------------------------------------------------------------- /src/viewProvider.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import * as path from 'path'; 3 | import * as fs from 'fs'; 4 | import mkdirp from 'mkdirp'; 5 | import rimraf from 'rimraf'; 6 | import * as Uri from 'vscode-uri'; 7 | import { Notes } from './extension'; 8 | 9 | //#region Utilities 10 | 11 | namespace _ { 12 | 13 | function handleResult(resolve: (result: T) => void, reject: (error: Error) => void, error: Error | null | undefined, result: T): void { 14 | if (error) { 15 | reject(massageError(error)); 16 | } else { 17 | resolve(result); 18 | } 19 | } 20 | 21 | function massageError(error: Error & { code?: string }): Error { 22 | if (error.code === 'ENOENT') { 23 | return vscode.FileSystemError.FileNotFound(); 24 | } 25 | 26 | if (error.code === 'EISDIR') { 27 | return vscode.FileSystemError.FileIsADirectory(); 28 | } 29 | 30 | if (error.code === 'EEXIST') { 31 | return vscode.FileSystemError.FileExists(); 32 | } 33 | 34 | if (error.code === 'EPERM' || error.code === 'EACCESS') { 35 | return vscode.FileSystemError.NoPermissions(); 36 | } 37 | 38 | return error; 39 | } 40 | 41 | export function checkCancellation(token: vscode.CancellationToken): void { 42 | if (token.isCancellationRequested) { 43 | throw new Error('Operation cancelled'); 44 | } 45 | } 46 | 47 | export function normalizeNFC(items: string): string; 48 | export function normalizeNFC(items: string[]): string[]; 49 | export function normalizeNFC(items: string | string[]): string | string[] { 50 | if (process.platform !== 'darwin') { 51 | return items; 52 | } 53 | 54 | if (Array.isArray(items)) { 55 | return items.map(item => item.normalize('NFC')); 56 | } 57 | 58 | return items.normalize('NFC'); 59 | } 60 | 61 | export function readdir(path: string): Promise { 62 | return new Promise((resolve, reject) => { 63 | fs.readdir(path, (error: NodeJS.ErrnoException | null, children) => handleResult(resolve, reject, error, normalizeNFC(children))); 64 | }); 65 | } 66 | 67 | export function stat(path: string): Promise { 68 | return new Promise((resolve, reject) => { 69 | fs.stat(path, (error: NodeJS.ErrnoException | null, stat) => handleResult(resolve, reject, error, stat)); 70 | }); 71 | } 72 | 73 | export function readfile(path: string): Promise { 74 | return new Promise((resolve, reject) => { 75 | fs.readFile(path, (error: NodeJS.ErrnoException | null, buffer) => handleResult(resolve, reject, error, buffer)); 76 | }); 77 | } 78 | 79 | export function writefile(path: string, content: Buffer): Promise { 80 | return new Promise((resolve, reject) => { 81 | fs.writeFile(path, content, (error: NodeJS.ErrnoException | null) => handleResult(resolve, reject, error, void 0)); 82 | }); 83 | } 84 | 85 | export function exists(path: string): Promise { 86 | return new Promise((resolve, reject) => { 87 | fs.exists(path, exists => handleResult(resolve, reject, null, exists)); 88 | }); 89 | } 90 | 91 | export function rmrf(path: string): Promise { 92 | return new Promise((resolve, reject) => { 93 | rimraf(path, (error: Error | null) => handleResult(resolve, reject, error, void 0)); 94 | }); 95 | } 96 | 97 | export function mkdir(path: string): Promise { 98 | return new Promise((resolve, reject) => { 99 | mkdirp(path).then(() => resolve()).catch((error: Error) => reject(error)); 100 | }); 101 | } 102 | 103 | export function rename(oldPath: string, newPath: string): Promise { 104 | return new Promise((resolve, reject) => { 105 | fs.rename(oldPath, newPath, (error: NodeJS.ErrnoException | null) => handleResult(resolve, reject, error, void 0)); 106 | }); 107 | } 108 | 109 | export function unlink(path: string): Promise { 110 | return new Promise((resolve, reject) => { 111 | fs.unlink(path, (error: NodeJS.ErrnoException | null) => handleResult(resolve, reject, error, void 0)); 112 | }); 113 | } 114 | } 115 | 116 | export class FileStat implements vscode.FileStat { 117 | 118 | constructor(private fsStat: fs.Stats) { } 119 | 120 | get type(): vscode.FileType { 121 | return this.fsStat.isFile() ? vscode.FileType.File : this.fsStat.isDirectory() ? vscode.FileType.Directory : this.fsStat.isSymbolicLink() ? vscode.FileType.SymbolicLink : vscode.FileType.Unknown; 122 | } 123 | 124 | get isFile(): boolean | undefined { 125 | return this.fsStat.isFile(); 126 | } 127 | 128 | get isDirectory(): boolean | undefined { 129 | return this.fsStat.isDirectory(); 130 | } 131 | 132 | get isSymbolicLink(): boolean | undefined { 133 | return this.fsStat.isSymbolicLink(); 134 | } 135 | 136 | get size(): number { 137 | return this.fsStat.size; 138 | } 139 | 140 | get ctime(): number { 141 | return this.fsStat.ctime.getTime(); 142 | } 143 | 144 | get mtime(): number { 145 | return this.fsStat.mtime.getTime(); 146 | } 147 | } 148 | 149 | interface Entry { 150 | uri: vscode.Uri; 151 | type: vscode.FileType; 152 | } 153 | 154 | //#endregion 155 | 156 | export class FileSystemProvider implements vscode.TreeDataProvider, vscode.FileSystemProvider { 157 | 158 | private _onDidChangeFile: vscode.EventEmitter; 159 | 160 | constructor( 161 | private notesLocation: string 162 | ) { 163 | this._onDidChangeFile = new vscode.EventEmitter(); 164 | } 165 | 166 | get onDidChangeFile(): vscode.Event { 167 | return this._onDidChangeFile.event; 168 | } 169 | 170 | watch(uri: vscode.Uri, options: { recursive: boolean; excludes: string[]; }): vscode.Disposable { 171 | // Use a more compatible version of fs.watch 172 | const watcher = fs.watch(uri.fsPath, async (event: string, filename: string | Buffer | null) => { 173 | if (filename) { 174 | const filepath = path.join(uri.fsPath, _.normalizeNFC(filename.toString())); 175 | 176 | // TODO support excludes (using minimatch library?) 177 | 178 | this._onDidChangeFile.fire([{ 179 | type: event === 'change' ? vscode.FileChangeType.Changed : await _.exists(filepath) ? vscode.FileChangeType.Created : vscode.FileChangeType.Deleted, 180 | uri: uri.with({ path: filepath }) 181 | } as vscode.FileChangeEvent]); 182 | } 183 | }); 184 | 185 | return { dispose: () => watcher.close() }; 186 | } 187 | 188 | stat(uri: vscode.Uri): vscode.FileStat | Thenable { 189 | return this._stat(uri.fsPath); 190 | } 191 | 192 | async _stat(path: string): Promise { 193 | return new FileStat(await _.stat(path)); 194 | } 195 | 196 | readDirectory(uri: vscode.Uri): [string, vscode.FileType][] | Thenable<[string, vscode.FileType][]> { 197 | return this._readDirectory(uri); 198 | } 199 | 200 | async _readDirectory(uri: vscode.Uri): Promise<[string, vscode.FileType][]> { 201 | const children = await _.readdir(uri.fsPath); 202 | 203 | const result: [string, vscode.FileType][] = []; 204 | for (let i = 0; i < children.length; i++) { 205 | const child = children[i]; 206 | const stat = await this._stat(path.join(uri.fsPath, child)); 207 | result.push([child, stat.type]); 208 | } 209 | 210 | return Promise.resolve(result); 211 | } 212 | 213 | createDirectory(uri: vscode.Uri): void | Thenable { 214 | return _.mkdir(uri.fsPath); 215 | } 216 | 217 | readFile(uri: vscode.Uri): Uint8Array | Thenable { 218 | return _.readfile(uri.fsPath); 219 | } 220 | 221 | writeFile(uri: vscode.Uri, content: Uint8Array, options: { create: boolean; overwrite: boolean; }): void | Thenable { 222 | return this._writeFile(uri, content, options); 223 | } 224 | 225 | async _writeFile(uri: vscode.Uri, content: Uint8Array, options: { create: boolean; overwrite: boolean; }): Promise { 226 | const exists = await _.exists(uri.fsPath); 227 | if (!exists) { 228 | if (!options.create) { 229 | throw vscode.FileSystemError.FileNotFound(); 230 | } 231 | 232 | await _.mkdir(path.dirname(uri.fsPath)); 233 | } else { 234 | if (!options.overwrite) { 235 | throw vscode.FileSystemError.FileExists(); 236 | } 237 | } 238 | 239 | return _.writefile(uri.fsPath, content as Buffer); 240 | } 241 | 242 | delete(uri: vscode.Uri, options: { recursive: boolean; }): void | Thenable { 243 | if (options.recursive) { 244 | return _.rmrf(uri.fsPath); 245 | } 246 | 247 | return _.unlink(uri.fsPath); 248 | } 249 | 250 | rename(oldUri: vscode.Uri, newUri: vscode.Uri, options: { overwrite: boolean; }): void | Thenable { 251 | return this._rename(oldUri, newUri, options); 252 | } 253 | 254 | async _rename(oldUri: vscode.Uri, newUri: vscode.Uri, options: { overwrite: boolean; }): Promise { 255 | const exists = await _.exists(newUri.fsPath); 256 | if (exists) { 257 | if (!options.overwrite) { 258 | throw vscode.FileSystemError.FileExists(); 259 | } else { 260 | await _.rmrf(newUri.fsPath); 261 | } 262 | } 263 | 264 | const parentExists = await _.exists(path.dirname(newUri.fsPath)); 265 | if (!parentExists) { 266 | await _.mkdir(path.dirname(newUri.fsPath)); 267 | } 268 | 269 | return _.rename(oldUri.fsPath, newUri.fsPath); 270 | } 271 | 272 | // tree data provider 273 | 274 | async getChildren(element?: Entry): Promise { 275 | if (element) { 276 | const children = await this.readDirectory(element.uri); 277 | return children.map(([name, type]) => ({ uri: vscode.Uri.file(path.join(element.uri.fsPath, name)), type })); 278 | } 279 | 280 | // const workspaceFolder = vscode.workspace.workspaceFolders.filter(folder => folder.uri.scheme === 'file')[0]; 281 | let notesFolder = Uri.URI.parse(this.notesLocation); 282 | 283 | if (notesFolder) { 284 | const children = await this.readDirectory(notesFolder); 285 | children.sort((a, b) => { 286 | if (a[1] === b[1]) { 287 | return a[0].localeCompare(b[0]); 288 | } 289 | return a[1] === vscode.FileType.Directory ? -1 : 1; 290 | }); 291 | return children.map(([name, type]) => ({ uri: vscode.Uri.file(path.join(notesFolder.fsPath, name)), type })); 292 | } 293 | 294 | return []; 295 | } 296 | 297 | getTreeItem(element: Entry): vscode.TreeItem { 298 | const treeItem = new vscode.TreeItem(element.uri, element.type === vscode.FileType.Directory ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.None); 299 | if (element.type === vscode.FileType.File) { 300 | treeItem.command = { command: 'fileExplorer.openFile', title: "Open File", arguments: [element.uri], }; 301 | treeItem.contextValue = 'file'; 302 | } 303 | return treeItem; 304 | } 305 | } 306 | 307 | export class FileExplorer { 308 | 309 | private fileExplorer: vscode.TreeView; 310 | private notesLocation = String(Notes.getNotesLocation()); 311 | 312 | constructor(context: vscode.ExtensionContext) { 313 | const treeDataProvider = new FileSystemProvider(this.notesLocation); 314 | this.fileExplorer = vscode.window.createTreeView('fileExplorer', { treeDataProvider }); 315 | vscode.commands.registerCommand('fileExplorer.openFile', (resource) => this.openResource(resource)); 316 | } 317 | 318 | private openResource(resource: vscode.Uri): void { 319 | vscode.window.showTextDocument(resource); 320 | } 321 | } 322 | -------------------------------------------------------------------------------- /src/extension.ts: -------------------------------------------------------------------------------- 1 | // figure out how to reload treeview when notes location changes 2 | import * as vscode from 'vscode'; 3 | import * as fs from 'fs'; 4 | import * as path from 'path'; 5 | import { Note } from './note'; 6 | import { NotesViewProvider } from './notesViewProvider'; 7 | 8 | let extId = 'vscode-notes'; 9 | let extPub = 'dionmunk'; 10 | 11 | // activate extension 12 | export function activate(context: vscode.ExtensionContext) { 13 | 14 | console.log('"vscode-notes" is active.'); 15 | 16 | // get Notes configuration 17 | let notesTree = new NotesViewProvider(String(Notes.getNotesLocation()), String(Notes.getNotesExtensions())); 18 | vscode.window.registerTreeDataProvider('notes', notesTree.init()); 19 | 20 | // Listen for configuration changes 21 | context.subscriptions.push( 22 | vscode.workspace.onDidChangeConfiguration(e => { 23 | // Check if notes.notesLocation setting changed 24 | if (e.affectsConfiguration('notes.notesLocation')) { 25 | // Prompt to reload window so storage location change can take effect 26 | vscode.window.showWarningMessage( 27 | `The Notes extension detected a change in the storage location. You must reload the window for the change to take effect.`, 28 | 'Reload' 29 | ).then(selectedAction => { 30 | // if the user selected to reload the window then reload 31 | if (selectedAction === 'Reload') { 32 | vscode.commands.executeCommand('workbench.action.reloadWindow'); 33 | } 34 | }); 35 | } 36 | }) 37 | ); 38 | 39 | /* 40 | * register commands 41 | */ 42 | 43 | // delete note 44 | let deleteNoteDisposable = vscode.commands.registerCommand('Notes.deleteNote', (note: Note) => { 45 | Notes.deleteNote(note, notesTree); 46 | }); 47 | context.subscriptions.push(deleteNoteDisposable); 48 | 49 | // delete folder 50 | let deleteFolderDisposable = vscode.commands.registerCommand('Notes.deleteFolder', (folder: Note) => { 51 | Notes.deleteFolder(folder, notesTree); 52 | }); 53 | context.subscriptions.push(deleteFolderDisposable); 54 | 55 | // list notes 56 | let listNotesDisposable = vscode.commands.registerCommand('Notes.listNotes', () => { 57 | Notes.listNotes(); 58 | }); 59 | context.subscriptions.push(listNotesDisposable); 60 | 61 | // new note 62 | let newNoteDisposable = vscode.commands.registerCommand('Notes.newNote', (folder?: Note) => { 63 | Notes.newNote(notesTree, folder); 64 | }); 65 | context.subscriptions.push(newNoteDisposable); 66 | 67 | // new folder 68 | let newFolderDisposable = vscode.commands.registerCommand('Notes.newFolder', (parentFolder?: Note) => { 69 | Notes.newFolder(notesTree, parentFolder); 70 | }); 71 | context.subscriptions.push(newFolderDisposable); 72 | 73 | // open note 74 | let openNoteDisposable = vscode.commands.registerCommand('Notes.openNote', (note: Note | string) => { 75 | Notes.openNote(note); 76 | }); 77 | context.subscriptions.push(openNoteDisposable); 78 | 79 | // refresh notes 80 | let refreshNotesDisposable = vscode.commands.registerCommand('Notes.refreshNotes', () => { 81 | Notes.refreshNotes(notesTree); 82 | }); 83 | context.subscriptions.push(refreshNotesDisposable); 84 | 85 | // rename note 86 | let renameNoteDisposable = vscode.commands.registerCommand('Notes.renameNote', (note: Note) => { 87 | Notes.renameNote(note, notesTree); 88 | }); 89 | context.subscriptions.push(renameNoteDisposable); 90 | 91 | // rename folder 92 | let renameFolderDisposable = vscode.commands.registerCommand('Notes.renameFolder', (folder: Note) => { 93 | Notes.renameFolder(folder, notesTree); 94 | }); 95 | context.subscriptions.push(renameFolderDisposable); 96 | 97 | // setup notes 98 | let setupNotesDisposable = vscode.commands.registerCommand('Notes.setupNotes', () => { 99 | Notes.setupNotes(); 100 | }); 101 | context.subscriptions.push(setupNotesDisposable); 102 | 103 | }; 104 | 105 | // this method is called when extension is deactivated 106 | export function deactivate() { 107 | /* 108 | * everything registered in context.subscriptions, 109 | * so nothing to do here for now 110 | */ 111 | } 112 | 113 | export class Notes { 114 | 115 | constructor( 116 | public settings: vscode.WorkspaceConfiguration 117 | ) { 118 | this.settings = vscode.workspace.getConfiguration(extId); 119 | } 120 | 121 | // get notes storage location 122 | static getNotesLocation() { 123 | return vscode.workspace.getConfiguration('notes').get('notesLocation'); 124 | } 125 | // get notes default extension 126 | static getNotesDefaultNoteExtension() { 127 | return vscode.workspace.getConfiguration('notes').get('notesDefaultNoteExtension'); 128 | } 129 | // get notes default extension 130 | static getNotesExtensions() { 131 | return vscode.workspace.getConfiguration('notes').get('notesExtensions'); 132 | } 133 | 134 | // delete note 135 | static deleteNote(note: Note, tree: NotesViewProvider): void { 136 | // prompt user for confirmation 137 | vscode.window.showWarningMessage(`Are you sure you want to delete '${note.name}'? This action is permanent and can not be reversed.`, 'Yes', 'No').then(result => { 138 | // if the user answers Yes 139 | if (result === 'Yes') { 140 | // try to delete the note 141 | fs.unlink(path.join(String(note.location), String(note.name)), (err) => { 142 | // if there was an error deleting the note 143 | if (err) { 144 | // report error 145 | console.error(err); 146 | return vscode.window.showErrorMessage(`Failed to delete ${note.name}.`); 147 | } 148 | // else let the user know the file was deleted successfully 149 | vscode.window.showInformationMessage(`Successfully deleted ${note.name}.`); 150 | }); 151 | // refresh tree after deleting note 152 | tree.refresh(); 153 | } 154 | }); 155 | } 156 | 157 | // delete folder 158 | static deleteFolder(folder: Note, tree: NotesViewProvider): void { 159 | if (!folder.isFolder) { 160 | vscode.window.showErrorMessage('Selected item is not a folder.'); 161 | return; 162 | } 163 | 164 | // prompt user for confirmation 165 | vscode.window.showWarningMessage(`Are you sure you want to delete folder '${folder.name}' and all its contents? This action is permanent and can not be reversed.`, 'Yes', 'No').then(result => { 166 | // if the user answers Yes 167 | if (result === 'Yes') { 168 | // try to delete the folder recursively 169 | const folderPath = path.join(folder.location, folder.name); 170 | 171 | // Use rimraf or fs.rmdir with recursive option 172 | const rimraf = require('rimraf'); 173 | rimraf(folderPath, (err: Error | null) => { 174 | // if there was an error deleting the folder 175 | if (err) { 176 | // report error 177 | console.error(err); 178 | vscode.window.showErrorMessage(`Failed to delete folder ${folder.name}.`); 179 | return; 180 | } 181 | // else let the user know the folder was deleted successfully 182 | vscode.window.showInformationMessage(`Successfully deleted folder ${folder.name}.`); 183 | 184 | // refresh tree after deleting folder 185 | tree.refresh(); 186 | }); 187 | } 188 | }); 189 | } 190 | 191 | // list notes 192 | static listNotes(): void { 193 | let notesLocation = String(Notes.getNotesLocation()); 194 | let notesExtensions = String(Notes.getNotesExtensions()); 195 | // read files in storage location 196 | fs.readdir(String(notesLocation), (err, files) => { 197 | if (err) { 198 | // report error 199 | console.error(err); 200 | return vscode.window.showErrorMessage('Failed to read the notes folder.'); 201 | } 202 | else { 203 | // show list of notes 204 | vscode.window.showQuickPick(files).then(file => { 205 | // open selected note 206 | vscode.window.showTextDocument(vscode.Uri.file(path.join(String(notesLocation), String(file)))); 207 | }); 208 | } 209 | }); 210 | } 211 | 212 | // new note 213 | static newNote(tree: NotesViewProvider, folder?: Note): void { 214 | // Determine the location where the note should be created 215 | let notesLocation = folder ? path.join(folder.location, folder.name) : String(Notes.getNotesLocation()); 216 | let notesDefaultNoteExtension = String(Notes.getNotesDefaultNoteExtension()); 217 | 218 | // prompt user for a new note name 219 | vscode.window.showInputBox({ 220 | prompt: 'Note name?', 221 | value: '', 222 | }).then(noteName => { 223 | if (!noteName) { 224 | return; // User cancelled 225 | } 226 | 227 | // set note name 228 | let fileName: string = `${noteName}`; 229 | // set note path 230 | let filePath: string = path.join(notesLocation, `${fileName.replace(/\:/gi, '')}.${notesDefaultNoteExtension}`); 231 | // set note first line 232 | let firstLine: string = "# " + fileName + "\n\n"; 233 | // does note exist already? 234 | let noteExists = fs.existsSync(String(filePath)); 235 | 236 | // if a note with name doesn't already exist 237 | if (!noteExists) { 238 | // try writing the file to the storage location 239 | fs.writeFile(filePath, firstLine, err => { 240 | if (err) { 241 | // report error 242 | console.error(err); 243 | return vscode.window.showErrorMessage('Failed to create the new note.'); 244 | } 245 | else { 246 | // open file 247 | let file = vscode.Uri.file(filePath); 248 | vscode.window.showTextDocument(file).then(() => { 249 | // go to last line in new file 250 | vscode.commands.executeCommand('cursorMove', { 'to': 'viewPortBottom' }); 251 | }); 252 | } 253 | }); 254 | // refresh tree after creating new note 255 | tree.refresh(); 256 | } 257 | else { 258 | // report 259 | return vscode.window.showWarningMessage('A note with that name already exists.'); 260 | } 261 | }); 262 | } 263 | 264 | // new folder 265 | static newFolder(tree: NotesViewProvider, parentFolder?: Note): void { 266 | // Determine the location where the folder should be created 267 | let parentLocation = parentFolder ? path.join(parentFolder.location, parentFolder.name) : String(Notes.getNotesLocation()); 268 | 269 | // prompt user for a new folder name 270 | vscode.window.showInputBox({ 271 | prompt: 'Folder name?', 272 | value: '', 273 | }).then(folderName => { 274 | if (!folderName) { 275 | return; // User cancelled 276 | } 277 | 278 | // set folder path 279 | let folderPath: string = path.join(parentLocation, folderName); 280 | 281 | // does folder exist already? 282 | let folderExists = fs.existsSync(String(folderPath)); 283 | 284 | // if a folder with name doesn't already exist 285 | if (!folderExists) { 286 | // try creating the folder 287 | fs.mkdir(folderPath, { recursive: true }, err => { 288 | if (err) { 289 | // report error 290 | console.error(err); 291 | return vscode.window.showErrorMessage('Failed to create the new folder.'); 292 | } 293 | else { 294 | vscode.window.showInformationMessage(`Successfully created folder ${folderName}.`); 295 | } 296 | }); 297 | // refresh tree after creating new folder 298 | tree.refresh(); 299 | } 300 | else { 301 | // report 302 | return vscode.window.showWarningMessage('A folder with that name already exists.'); 303 | } 304 | }); 305 | } 306 | 307 | // open note 308 | static openNote(note: Note | string): void { 309 | // If it's a Note object and a folder, don't try to open it 310 | if (typeof note !== 'string' && note.isFolder) { 311 | return; 312 | } 313 | 314 | let filePath: string; 315 | 316 | // If note is a string (full path) 317 | if (typeof note === 'string') { 318 | // Use the path directly 319 | filePath = note; 320 | } 321 | // If note is a Note object 322 | else { 323 | // Use the note's location and name to construct the path 324 | filePath = path.join(String(note.location), String(note.name)); 325 | } 326 | 327 | // Open the document 328 | vscode.window.showTextDocument(vscode.Uri.file(filePath)); 329 | } 330 | 331 | // refresh notes 332 | static refreshNotes(tree: NotesViewProvider): void { 333 | // refresh tree 334 | tree.refresh(); 335 | } 336 | 337 | // rename note 338 | static renameNote(note: Note, tree: NotesViewProvider): void { 339 | // If it's a folder, don't try to rename it as a note 340 | if (note.isFolder) { 341 | return; 342 | } 343 | 344 | // get the note's extension 345 | let noteExtension = note.name.split('.').pop(); 346 | 347 | // prompt user for new note name 348 | vscode.window.showInputBox({ 349 | prompt: 'New note name?', 350 | value: note.name 351 | }).then(newNoteName => { 352 | // if no new note name or note name didn't change 353 | if (!newNoteName || newNoteName === note.name) { 354 | // do nothing 355 | return; 356 | } 357 | 358 | // Get the extension without the dot 359 | let newNoteExtension = path.extname(newNoteName).replace('.', ''); 360 | let noteName: string = ''; 361 | 362 | // if new note name extension is in list of allowed extensions 363 | if (String(Notes.getNotesExtensions()).split(',').includes(newNoteExtension)) { 364 | // use the new note name 365 | noteName = newNoteName; 366 | } 367 | // else if new note name has no extension 368 | else if (path.extname(newNoteName) === '') { 369 | // use the note's current extension 370 | noteName = newNoteName + '.' + noteExtension; 371 | } 372 | // else if new note name has an extension that's not in the allowed list 373 | else { 374 | // use the new note name but with the current extension 375 | noteName = path.basename(newNoteName, path.extname(newNoteName)) + '.' + noteExtension; 376 | } 377 | 378 | // check for existing note with the same name 379 | let newNotePath = path.join(note.location, noteName); 380 | if (fs.existsSync(newNotePath)) { 381 | vscode.window.showWarningMessage(`'${noteName}' already exists.`); 382 | // do nothing 383 | return; 384 | } 385 | 386 | // else save the note 387 | vscode.window.showInformationMessage(`'${note.name}' renamed to '${noteName}'.`); 388 | fs.renameSync(path.join(note.location, note.name), newNotePath); 389 | 390 | // refresh tree after renaming note 391 | tree.refresh(); 392 | }); 393 | } 394 | 395 | // rename folder 396 | static renameFolder(folder: Note, tree: NotesViewProvider): void { 397 | // If it's not a folder, don't try to rename it as a folder 398 | if (!folder.isFolder) { 399 | return; 400 | } 401 | 402 | // prompt user for new folder name 403 | vscode.window.showInputBox({ 404 | prompt: 'New folder name?', 405 | value: folder.name 406 | }).then(newFolderName => { 407 | // if no new folder name or folder name didn't change 408 | if (!newFolderName || newFolderName === folder.name) { 409 | // do nothing 410 | return; 411 | } 412 | 413 | // check for existing folder with the same name 414 | let newFolderPath = path.join(folder.location, newFolderName); 415 | if (fs.existsSync(newFolderPath)) { 416 | vscode.window.showWarningMessage(`'${newFolderName}' already exists.`); 417 | // do nothing 418 | return; 419 | } 420 | 421 | // else rename the folder 422 | vscode.window.showInformationMessage(`'${folder.name}' renamed to '${newFolderName}'.`); 423 | fs.renameSync(path.join(folder.location, folder.name), newFolderPath); 424 | 425 | // refresh tree after renaming folder 426 | tree.refresh(); 427 | }); 428 | } 429 | 430 | // setup notes 431 | static setupNotes(tree?: NotesViewProvider): void { 432 | // Check if notesLocation is not null 433 | const notesLocation = Notes.getNotesLocation(); 434 | if (notesLocation) { 435 | // If notesLocation is not null, take the user to the extension settings 436 | vscode.commands.executeCommand('workbench.action.openSettings', `@ext:dionmunk.vscode-notes`); 437 | return; 438 | } 439 | 440 | // If notesLocation is null, show dialog to select a folder 441 | let openDialogOptions: vscode.OpenDialogOptions = { 442 | canSelectFiles: false, 443 | canSelectFolders: true, 444 | canSelectMany: false, 445 | openLabel: 'Select' 446 | }; 447 | 448 | // display open dialog with above options 449 | vscode.window.showOpenDialog(openDialogOptions).then(fileUri => { 450 | if (fileUri && fileUri[0]) { 451 | // get Notes configuration 452 | let notesConfiguration = vscode.workspace.getConfiguration('notes'); 453 | // update Notes configuration with selected location 454 | notesConfiguration.update('notesLocation', path.normalize(fileUri[0].fsPath), true).then(() => { 455 | // prompt to reload window so storage location change can take effect 456 | vscode.window.showWarningMessage( 457 | `The Notes extension detected a change in the storage location. You must reload the window for the change to take effect.`, 458 | 'Reload' 459 | ).then(selectedAction => { 460 | // if the user selected to reload the window then reload 461 | if (selectedAction === 'Reload') { 462 | vscode.commands.executeCommand('workbench.action.reloadWindow'); 463 | } 464 | }); 465 | }); 466 | } 467 | }); 468 | } 469 | } 470 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Attribution-NonCommercial 4.0 International 2 | 3 | Creative Commons Corporation ("Creative Commons") is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an "as-is" basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. 4 | 5 | Using Creative Commons Public Licenses 6 | 7 | Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. 8 | 9 | Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors : wiki.creativecommons.org/Considerations_for_licensors 10 | 11 | Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor's permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public : wiki.creativecommons.org/Considerations_for_licensees 12 | 13 | Creative Commons Attribution-NonCommercial 4.0 International Public License 14 | 15 | By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. 16 | 17 | Section 1 – Definitions. 18 | 19 | a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. 20 | b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. 21 | c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. 22 | d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. 23 | e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. 24 | f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. 25 | g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. 26 | h. Licensor means the individual(s) or entity(ies) granting rights under this Public License. 27 | i. NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange. 28 | j. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. 29 | k. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. 30 | l. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. 31 | Section 2 – Scope. 32 | 33 | a. License grant. 34 | 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: 35 | A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and 36 | B. produce, reproduce, and Share Adapted Material for NonCommercial purposes only. 37 | 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 38 | 3. Term. The term of this Public License is specified in Section 6(a). 39 | 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. 40 | 5. Downstream recipients. 41 | A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. 42 | B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 43 | 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). 44 | b. Other rights. 45 | 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 46 | 2. Patent and trademark rights are not licensed under this Public License. 47 | 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes. 48 | Section 3 – License Conditions. 49 | 50 | Your exercise of the Licensed Rights is expressly made subject to the following conditions. 51 | 52 | a. Attribution. 53 | 1. If You Share the Licensed Material (including in modified form), You must: 54 | A. retain the following if it is supplied by the Licensor with the Licensed Material: 55 | i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); 56 | ii. a copyright notice; 57 | iii. a notice that refers to this Public License; 58 | iv. a notice that refers to the disclaimer of warranties; 59 | v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; 60 | B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and 61 | C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 62 | 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 63 | 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 64 | 4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License. 65 | Section 4 – Sui Generis Database Rights. 66 | 67 | Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: 68 | 69 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only; 70 | b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and 71 | c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. 72 | For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. 73 | 74 | Section 5 – Disclaimer of Warranties and Limitation of Liability. 75 | 76 | a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. 77 | b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. 78 | c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. 79 | Section 6 – Term and Termination. 80 | 81 | a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. 82 | b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 83 | 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 84 | 2. upon express reinstatement by the Licensor. 85 | For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. 86 | 87 | c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. 88 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. 89 | Section 7 – Other Terms and Conditions. 90 | 91 | a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. 92 | b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. 93 | Section 8 – Interpretation. 94 | 95 | a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. 96 | b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. 97 | c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. 98 | d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. 99 | Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the "Licensor." The text of the Creative Commons public licenses is dedicated to the public domain under the CC0 Public Domain Dedication. Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark "Creative Commons" or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. 100 | 101 | Creative Commons may be contacted at creativecommons.org. --------------------------------------------------------------------------------