kookma / TW-Shiraz

Shiraz is a small Tiddlywiki 5 plugin contains macros, stylesheets, templates, snippets, images, static tables, dynamic tables and acts as a starter kit.
https://kookma.github.io/TW-Shiraz/
78 stars 8 forks source link

[Feature Request] Provide Snippets #22

Open linonetwo opened 2 years ago

linonetwo commented 2 years ago

Hi Mohammad, I have been using your great plugins for a while, they help me a lot both in my public and private wikis!

I found one thing that may have a huge positive impact on your plugin libraries: Would you consider adding snippets to your plugin?

For example, this is the one added by myself into my wiki:

截屏2021-10-02 下午4 14 59

Then I can use your dynamic table more easily, without the need to open the document site and copy the code.

截屏2021-10-02 下午4 16 08

Your document site is beautiful and very clear, but I think for the most case, the API of your macro is clear enough, so we might not need to read the document, and can just figure out how to use these macros by looking at the fields.

So it will be much convenient if you bundle some snippets alongside with your plugins!


P.S. Gk0Wk is creating a code mirror plugin that will list tiddlers with $:/tags/TextEditor/Snippet tag, if the user types / in the editor. It will feel just like how notion and other modern note app works. (base framework is in https://github.com/Gk0Wk/TW5-CodeMirror-Enhanced , he is working on snippet feature today, not complete yet)

linonetwo commented 2 years ago
截屏2021-11-03 上午12 03 00

We can use snippets like this, using / command.

kookma commented 2 years ago

Hi @linonetwo! good idea! I will add some snippets! just let me to find some free time! I added this to todo list!

linonetwo commented 2 years ago

@Gk0Wk can we let 3rd party snippet have preview (usage demo) field too?

Gk0Wk commented 2 years ago

@linonetwo yes, but the CME plugin missing a lot of documents. That is the problem.

@kookma If you would like to add some snippets, just add a tiddler with the type of application/json and the tag of $:/CodeMirrorEnhanced/SnippetsList in your plugin, then the CME plugin will find it. The format of this tiddler can be found here:


Another way is to use TW's native snippet system. And the snippet-description field is equal to preview attribute. And placeholders $x can also work.

linonetwo commented 2 years ago

Maybe should have both $:/CodeMirrorEnhanced/SnippetsList and $:/tags/TextEditor/Snippet

So it can be in both cme / menu and official snippet menu.

kookma commented 2 years ago

@Gk0Wk - Thank you for the instruction! I will add both!

Gk0Wk commented 2 years ago

CME can read system snippets, too. If you write both types of them, snippets may appear twice. So should just write system snippets.

linonetwo commented 2 years ago

@Gk0Wk I think tiddler with fields for both system and cme, and tag for both, can work in both side.