Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Feature Request] Provide Snippets #22

Open
linonetwo opened this issue Oct 2, 2021 · 8 comments
Open

[Feature Request] Provide Snippets #22

linonetwo opened this issue Oct 2, 2021 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@linonetwo
Copy link

linonetwo commented Oct 2, 2021

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
Copy link
Author

截屏2021-11-03 上午12 03 00

We can use snippets like this, using / command.

@kookma kookma added the enhancement New feature or request label Nov 4, 2021
@kookma kookma changed the title Provide Snippets [Idea] Provide Snippets Nov 4, 2021
@kookma kookma changed the title [Idea] Provide Snippets [Feature Request] Provide Snippets Nov 4, 2021
@kookma kookma self-assigned this Nov 4, 2021
@kookma
Copy link
Owner

kookma commented Nov 4, 2021

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

@linonetwo
Copy link
Author

linonetwo commented Nov 4, 2021

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

@Gk0Wk
Copy link

Gk0Wk commented Nov 4, 2021

@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:

  • The 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.
  • Note that both 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.

@linonetwo
Copy link
Author

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

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

@kookma
Copy link
Owner

kookma commented Nov 4, 2021

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

@Gk0Wk
Copy link

Gk0Wk commented Nov 4, 2021

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

@linonetwo
Copy link
Author

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants