-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ef728d9
Showing
14 changed files
with
405 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"root": true, | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"rules": { | ||
"@typescript-eslint/class-name-casing": "warn", | ||
"@typescript-eslint/semi": "warn", | ||
"curly": "warn", | ||
"eqeqeq": "warn", | ||
"no-throw-literal": "warn", | ||
"semi": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
out | ||
node_modules | ||
.vscode-test/ | ||
*.vsix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// A launch configuration that compiles the extension and then opens it inside a new window | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Run Extension", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"runtimeExecutable": "${execPath}", | ||
"args": [ | ||
"--extensionDevelopmentPath=${workspaceFolder}" | ||
], | ||
"outFiles": [ | ||
"${workspaceFolder}/out/**/*.js" | ||
], | ||
"preLaunchTask": "${defaultBuildTask}" | ||
}, | ||
{ | ||
"name": "Extension Tests", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"runtimeExecutable": "${execPath}", | ||
"args": [ | ||
"--extensionDevelopmentPath=${workspaceFolder}", | ||
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index" | ||
], | ||
"outFiles": [ | ||
"${workspaceFolder}/out/test/**/*.js" | ||
], | ||
"preLaunchTask": "${defaultBuildTask}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
"files.exclude": { | ||
"out": false // set this to true to hide the "out" folder with the compiled JS files | ||
}, | ||
"search.exclude": { | ||
"out": true // set this to false to include "out" folder in search results | ||
}, | ||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts | ||
"typescript.tsc.autoDetect": "off" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "npm", | ||
"script": "watch", | ||
"problemMatcher": "$tsc-watch", | ||
"isBackground": true, | ||
"presentation": { | ||
"reveal": "never" | ||
}, | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.vscode/** | ||
.vscode-test/** | ||
out/test/** | ||
src/** | ||
.gitignore | ||
vsc-extension-quickstart.md | ||
**/tsconfig.json | ||
**/.eslintrc.json | ||
**/*.map | ||
**/*.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Change Log | ||
|
||
All notable changes to the "zknotes" extension will be documented in this file. | ||
|
||
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. | ||
|
||
## [Unreleased] | ||
|
||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# zknotes README | ||
|
||
This is the README for your extension "zknotes". After writing up a brief description, we recommend including the following sections. | ||
|
||
## Features | ||
|
||
Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file. | ||
|
||
For example if there is an image subfolder under your extension project workspace: | ||
|
||
\!\[feature X\]\(images/feature-x.png\) | ||
|
||
> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow. | ||
## Requirements | ||
|
||
If you have any requirements or dependencies, add a section describing those and how to install and configure them. | ||
|
||
## Extension Settings | ||
|
||
Include if your extension adds any VS Code settings through the `contributes.configuration` extension point. | ||
|
||
For example: | ||
|
||
This extension contributes the following settings: | ||
|
||
* `myExtension.enable`: enable/disable this extension | ||
* `myExtension.thing`: set to `blah` to do something | ||
|
||
## Known Issues | ||
|
||
Calling out known issues can help limit users opening duplicate issues against your extension. | ||
|
||
## Release Notes | ||
|
||
Users appreciate release notes as you update your extension. | ||
|
||
### 1.0.0 | ||
|
||
Initial release of ... | ||
|
||
### 1.0.1 | ||
|
||
Fixed issue #. | ||
|
||
### 1.1.0 | ||
|
||
Added features X, Y, and Z. | ||
|
||
----------------------------------------------------------------------------------------------------------- | ||
|
||
## Working with Markdown | ||
|
||
**Note:** You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts: | ||
|
||
* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux) | ||
* Toggle preview (`Shift+CMD+V` on macOS or `Shift+Ctrl+V` on Windows and Linux) | ||
* Press `Ctrl+Space` (Windows, Linux) or `Cmd+Space` (macOS) to see a list of Markdown snippets | ||
|
||
### For more information | ||
|
||
* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown) | ||
* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/) | ||
|
||
**Enjoy!** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"name": "zknotes", | ||
"displayName": "zknotes", | ||
"description": "vscode plugin for zk", | ||
"version": "0.0.1", | ||
"engines": { | ||
"vscode": "^1.45.0" | ||
}, | ||
"categories": [ | ||
"Other" | ||
], | ||
"activationEvents": [ | ||
"onCommand:zknotes.helloWorld", | ||
"onCommand:zknotes.newNote" | ||
], | ||
"main": "./out/extension.js", | ||
"configuration": { | ||
"type": "object", | ||
"title": "zknotes configuration", | ||
"properties": { | ||
"zknotes.defaultFormat": { | ||
"type": "string", | ||
"default": "yyyyMMddHHmm", | ||
"description": "zk new note default format" | ||
} | ||
} | ||
}, | ||
"contributes": { | ||
"commands": [ | ||
{ | ||
"command": "zknotes.helloWorld", | ||
"title": "Hello World" | ||
}, | ||
{ | ||
"command": "zknotes.newNote", | ||
"title": "new zk note" | ||
} | ||
] | ||
}, | ||
"scripts": { | ||
"vscode:prepublish": "npm run compile", | ||
"compile": "tsc -p ./", | ||
"lint": "eslint src --ext ts", | ||
"watch": "tsc -watch -p ./", | ||
"pretest": "npm run compile && npm run lint", | ||
"test": "node ./out/test/runTest.js" | ||
}, | ||
"devDependencies": { | ||
"@types/vscode": "^1.45.0", | ||
"@types/glob": "^7.1.1", | ||
"@types/mocha": "^7.0.2", | ||
"@types/node": "^13.11.0", | ||
"eslint": "^6.8.0", | ||
"@typescript-eslint/parser": "^2.30.0", | ||
"@typescript-eslint/eslint-plugin": "^2.30.0", | ||
"glob": "^7.1.6", | ||
"mocha": "^7.1.2", | ||
"typescript": "^3.8.3", | ||
"vscode-test": "^1.3.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// The module 'vscode' contains the VS Code extensibility API | ||
// Import the module and reference it with the alias vscode in your code below | ||
import * as vscode from 'vscode'; | ||
|
||
import { | ||
exists, | ||
mkdir, | ||
writeFile, | ||
readFile, | ||
readdir, | ||
symlink, | ||
copyFile, | ||
stat, | ||
} from 'fs'; | ||
import { formatDate } from './utils'; | ||
|
||
|
||
// this method is called when your extension is activated | ||
// your extension is activated the very first time the command is executed | ||
export function activate(context: vscode.ExtensionContext) { | ||
|
||
// Use the console to output diagnostic information (console.log) and errors (console.error) | ||
// This line of code will only be executed once when your extension is activated | ||
console.log('Congratulations, your extension "zknotes" is now active!'); | ||
|
||
// The command has been defined in the package.json file | ||
// Now provide the implementation of the command with registerCommand | ||
// The commandId parameter must match the command field in package.json | ||
let disposable = vscode.commands.registerCommand('zknotes.helloWorld', () => { | ||
// The code you place here will be executed every time your command is executed | ||
|
||
// Display a message box to the user | ||
vscode.window.showInformationMessage('Hello World from zknotes!'); | ||
}); | ||
|
||
context.subscriptions.push(disposable); | ||
|
||
|
||
let createNewNote = vscode.commands.registerCommand('zknotes.newNote', () => { | ||
// 按照zk默认格式进行新文件创建 | ||
// yyyyMMddHHmmss_dsds | ||
const root = vscode.workspace.rootPath; | ||
|
||
// 提示输入标题 | ||
vscode.window.showInputBox({ | ||
placeHolder: 'input your note title', | ||
prompt: 'enter your zk note title, or esc to cancel' | ||
}).then((inputValue) => { | ||
// 在当前目录下创建新的文件 | ||
|
||
// 增加时间戳 | ||
const config = vscode.workspace.getConfiguration('zknotes') | ||
const defaultFormat: string = config.get('defaultFormat') || '' | ||
const timestamp = formatDate(new Date(), defaultFormat) | ||
|
||
// 如果设置为空 则不增加前缀 | ||
const filename = defaultFormat ? `${timestamp}_${inputValue}` : inputValue | ||
|
||
vscode.window.showInputBox({ | ||
value: filename, | ||
prompt: 'confirm your note title' | ||
}).then(fullFilename => { | ||
writeFile(`${root}/${fullFilename}.md`, '', () => { | ||
vscode.window.showInformationMessage('success!') | ||
}) | ||
}) | ||
}) | ||
|
||
}); | ||
|
||
context.subscriptions.push(createNewNote) | ||
|
||
} | ||
|
||
// this method is called when your extension is deactivated | ||
export function deactivate() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
export function formatDate(date: Date, fmt: string | null) { | ||
var o = { | ||
'M+': date.getMonth() + 1, //月份 | ||
'd+': date.getDate(), //日 | ||
'h+': date.getHours(), //小时 | ||
'm+': date.getMinutes(), //分 | ||
's+': date.getSeconds(), //秒 | ||
'q+': Math.floor((date.getMonth() + 3) / 3), //季度 | ||
'S': date.getMilliseconds() //毫秒˝ | ||
}; | ||
if (!fmt) { | ||
fmt = 'yyyy-MM-dd hh:mm:ss'; | ||
} | ||
if (/(y+)/.test(fmt)) { | ||
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)); | ||
} | ||
for (var k in o) { | ||
if (new RegExp('(' + k + ')').test(fmt)) { | ||
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))); | ||
} | ||
} | ||
return fmt; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es6", | ||
"outDir": "out", | ||
"lib": [ | ||
"es6" | ||
], | ||
"sourceMap": true, | ||
"rootDir": "src", | ||
"strict": true /* enable all strict type-checking options */ | ||
/* Additional Checks */ | ||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ | ||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ | ||
// "noUnusedParameters": true, /* Report errors on unused parameters. */ | ||
}, | ||
"exclude": [ | ||
"node_modules", | ||
".vscode-test" | ||
] | ||
} |
Oops, something went wrong.