Skip to content

Commit 7f28863

Browse files
committed
Add documentations
1 parent b1130e9 commit 7f28863

File tree

4 files changed

+67
-13
lines changed

4 files changed

+67
-13
lines changed

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
/dist
77
tsconfig.json
88
webpack.config.js
9+
/docs

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Hieu-Thi Luong
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+45-13
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,56 @@
1-
# Joplin Plugin
1+
# Slash Commands: Datetime & More
22

3-
This is a template to create a new Joplin plugin.
3+
This plugin is a collection of utility commands that can be executed by typing corresponding keywords, which start with a slash ('/'). Current version only supports two type of commands but more might be added in the future.
44

5-
The main two files you will want to look at are:
65

7-
- `/src/index.ts`, which contains the entry point for the plugin source code.
8-
- `/src/manifest.json`, which is the plugin manifest. It contains information such as the plugin a name, version, etc.
6+
![screencap](https://raw.githubusercontent.com/hieuthi/joplin-plugin-slash-commands/main/docs/slash-commands-v1.0.0-screencap.gif)
97

10-
## Building the plugin
118

12-
The plugin is built using Webpack, which creates the compiled code in `/dist`. A JPL archive will also be created at the root, which can use to distribute the plugin.
9+
## Usage
10+
### String Command
11+
- String commands simply replace a keyword with one of the predefined strings.
12+
- **Built-in**: `/greet`, `/task`, `todotxt`
13+
- **Definition**: `[ "string" , "<keyword>", ["<string1>", "<string2" ] ]`
1314

14-
To build the plugin, simply run `npm run dist`.
15+
### Datetime Command
16+
- Datetime commands print out the current now with one of the predefined datestring format. Optionally you can offset the time by day, hour, and minutes
17+
- **Built-in**: `/now`, `/date`, `/time`, `/todoa`, `/todob`, `/todoc`, `/todod`, `/todoe`
18+
- **Offset examples**: adding `/now+d-H:M`, subtracting `/now-d-H:M`
19+
- **Offset formats**: `d-H:M`, `d-H`, `H:M`, `d`
20+
- **Definition**: `[ "string" , "<keyword>", ["<format1>", "<format2>" ] ]`
21+
- This command uses [Javascript Date Format](https://blog.stevenlevithan.com/archives/date-time-format) to parse datestring. You can check the original library on how to form your own `format`.
1522

16-
The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
23+
### Customization
24+
Even though there is only several types of commands, you can create many useful commands to serve your needs by setting the command definitions in the plugin setting by yourself. The commands definitions is an array of array but due to some awkwardness with Javascript and JSON string parse you need to carefully escape it.
1725

18-
## Updating the plugin framework
26+
```
27+
[
28+
["datetime", "now", [ "dd/mm/yyyy HH:MM", "yyyy-mm-dd\"T\"HH:MM:ss" ] ],
29+
["datetime", "date", [ "dd/mm/yyyy", "yyyy-mm-dd" ] ],
30+
["datetime", "time", [ "HH:MM", "HH:MM:ss" ] ],
31+
["string", "greet", [ "Hello World" ] ],
32+
["string", "task", [ "- [ ] " ] ],
33+
["string", "todotxt", [ "```todotxt sort:default\n\n```" ] ],
34+
["datetime", "todoa", [ "\"(A)\" yyyy-mm-dd " ] ],
35+
["datetime", "todob", [ "\"(B)\" yyyy-mm-dd " ] ],
36+
["datetime", "todoc", [ "\"(C)\" yyyy-mm-dd " ] ],
37+
["datetime", "todod", [ "\"(D)\" yyyy-mm-dd " ] ],
38+
["datetime", "todoe", [ "\"(E)\" yyyy-mm-dd " ] ]
39+
]
40+
```
1941

20-
To update the plugin framework, run `npm run update`.
42+
There is another awkwardness with Joplin Plugin Setting that only accept a single line value so you need to minify it like this.
2143

22-
In general this command tries to do the right thing - in particular it's going to merge the changes in package.json and .gitignore instead of overwriting. It will also leave "/src" as well as README.md untouched.
44+
```
45+
[["datetime", "now", [ "dd/mm/yyyy HH:MM", "yyyy-mm-dd\"T\"HH:MM:ss" ] ], ["datetime", "date", [ "dd/mm/yyyy", "yyyy-mm-dd" ] ], ["datetime", "time", [ "HH:MM", "HH:MM:ss" ] ], ["string", "greet", [ "Hello World" ] ], ["string", "task", [ "- [ ] " ] ], ["string", "todotxt", [ "```todotxt sort:default\n\n```" ] ], ["datetime", "todoa", [ "\"(A)\" yyyy-mm-dd " ] ], ["datetime", "todob", [ "\"(B)\" yyyy-mm-dd " ] ], ["datetime", "todoc", [ "\"(C)\" yyyy-mm-dd " ] ], ["datetime", "todod", [ "\"(D)\" yyyy-mm-dd " ] ], ["datetime", "todoe", [ "\"(E)\" yyyy-mm-dd " ] ] ]
46+
```
2347

24-
The file that may cause problem is "webpack.config.js" because it's going to be overwritten. For that reason, if you want to change it, consider creating a separate JavaScript file and include it in webpack.config.js. That way, when you update, you only have to restore the line that include your file.
48+
I will try to improve the configuration process when I find a better solution. If you messed with the setting and the plugin is no longer work, try paste the above definitions to your setting.
49+
50+
## Acknowledgements
51+
- Many thanks to @roman-r-m for the great [Quick Link](https://github.com/roman-r-m/joplin-plugin-quick-links) plugin which I used a lot and also a reference for this plugin
52+
- And Steven Levithan for a simple and easy-to-use [JavaScript Date Format Library](https://blog.stevenlevithan.com/archives/date-time-format)
53+
54+
## License
55+
56+
[MIT](https://raw.githubusercontent.com/hieuthi/joplin-plugin-slash-commands/main/LICENSE)
1.86 MB
Loading

0 commit comments

Comments
 (0)