Open linonetwo opened 2 years ago
We can use snippets like this, using /
command.
Hi @linonetwo! good idea! I will add some snippets! just let me to find some free time! I added this to todo list!
@Gk0Wk can we let 3rd party snippet have preview (usage demo) field too?
@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:
id
is the unique identifier of the snippet, entering /<id>
will display the corresponding snippet;name
is the name and title of the snippet, not necessarily unique;preview
is the preview effect of the snippet, when the snippet is selected in the hint of the CME plugin, it will be rendered in the preview box on the right.name
and preview
can support i18n (multi-language), the i18n
property is the multi-language function switch, if needed, I will write the usage in the future document, if not, please set it to false for now.snippet
is the native content of the snippet. In the hint function of the CME plugin, the selected snippet will write the snippet
content to the editor, where $x
is a placeholder and will be directly replaced by the cursor. The current cursor will only move to $1
, and may move to all $1
in the future.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.
Maybe should have both $:/CodeMirrorEnhanced/SnippetsList and $:/tags/TextEditor/Snippet
So it can be in both cme / menu and official snippet menu.
@Gk0Wk - Thank you for the instruction! I will add both!
CME can read system snippets, too. If you write both types of them, snippets may appear twice. So should just write system snippets.
@Gk0Wk I think tiddler with fields for both system and cme, and tag for both, can work in both side.
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:
Then I can use your dynamic table more easily, without the need to open the document site and copy the code.
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)