hieuthi / joplin-plugin-slash-commands

This plugin is a collection of utility commands that can be executed by typing corresponding keywords, which start with a slash.
MIT License
43 stars 7 forks source link

Slash Commands: Datetime & More

This plugin is a collection of utility commands that can be executed by typing corresponding keywords, which start with a slash. Current version supports three type of commands but more may be added in the future.

screencap

Usage

String Command

Datetime Command

Calendar Command

      December 2021       
Su  Mo  Tu  We  Th  Fr  Sa
             1   2   3   4
 5   6   7   8   9  10  11
12  13  14  15  16  17  18
19  20  21  22  23  24  25
26  27  28  29  30  31

Customization

Even though there is only several types of commands, you can create many commands by set 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.

[
  ["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" ] ],
  ["datetime", "jdate", [ "yyyy年mm月dd日(ddd)"], { "dayNames": ["日", "月", "火", "水", "木", "金", "土", "日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"], "monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月", "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"]}],
  ["string", "greet", [ "Hello", "你好", "Bonjour", "Hallo", "नमस्ते", "こんにちは", "안녕하세요", "Hola", "Xin chào" ] ],
  ["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 " ] ],
  ["calendar", "calendar", [null,"en-US","ja-JP"] ]
]

There is another awkwardness with Joplin Plugin Setting that only accept a single line value so you need to minify it like this.

[ ["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" ] ], ["datetime", "jdate", [ "yyyy年mm月dd日(ddd)"], { "dayNames": ["日", "月", "火", "水", "木", "金", "土", "日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"], "monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月", "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"]}], ["string", "greet", [ "Hello", "你好", "Bonjour", "Hallo", "नमस्ते", "こんにちは", "안녕하세요", "Hola", "Xin chào" ] ], ["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 " ] ], ["calendar", "calendar", [null,"en-US","ja-JP"]] ]

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 or just leave the setting BLANK the plugin will automatically revert it back to the DEFAULT definition.

Acknowledgements

License

MIT