kortina / vscode-markdown-notes

Install from: https://ark.dance/md-notes
GNU General Public License v3.0
425 stars 65 forks source link

Customize 'Unique ID' for ZK users #201

Open Liqiduan opened 5 months ago

Liqiduan commented 5 months ago

Background

That is not a problem, but an enhancement that other may need (like #105).

I think there are many users are starter who try to using ZK methods for note taking, just like me.

But the describe in #105 is not so proper. The feature we need is not "fuzzy search some word of tilte", indeed it‘s a way we address a note.

So the "part" here is the unique ID which use to distinguish between different notes.

The more widely used format of unique ID is form with date like 202405022227, but different user may have different ID system. For example, I like to use a short date with a counter like 20240502_01.

In summary, I really want to customize the format (maybe using a regex?), so that the backlink/wikilink can work well with the "unique ID".

Requested Feature

In brief:

  1. The Basic: Custom setting the 'unique ID' pattern, and work coperate with wikiLink/backlink/complete/reference.
  2. Advanced: ID generator help create note from 'unexisted' link.

Below are detail descirbe:

Describe to: Custom setting the 'unique ID' pattern, and work coperate with wikiLink/backlink.

Supports user using a unique ID like 202405022227 (YYMMDDHHMMSS), so the notes under directory notes may look like:

- notes
    - 202405022227-some-note-a.md
    - 202405022238-some-note-b.md

So the link [[202405022227]]/[note-b](202405022238) want to link to 202405022227-some-note-a.md and 202405022238-some-note-b.md.

Some things that link to [[202405022227]].
Here is and other line want to reference to [note-b](202405022238).

Seems using a unique ID means pepole want to change the title without change the link. So after rename these 2 files to below, the link [[202405022227]] will automaticly change to 202405022227-some-note-a-modifyed.md and also the [note-b](202405022238) change to 202405022238-some-note-b-new-version.md:

- notes
    - 202405022227-some-note-a-modifyed.md
    - 202405022238-some-note-b-new-version.md

And here are some advise for implement:

  1. Allow user set a regex pattern for unique ID. Different people have different ID format, so they can customize it. And I think this extension not need to check the "unique" of ID, the one use this feature will guard it.
  2. Change the "NoteNameFuzzyMatch" to Identy the unique file. filename and unique ID are different way but do the same thing Identy a note. So maybe using a 'unique ID' concept in system scope may help implement that and not affect to other features like backlink.

Here is an implement for that: #202

Describe to: Advanced: ID generator help create note from 'unexisted' link.

Sorry that I am tired today, and i will complete this part latter.

Other Feature & Problem Related

kortina commented 5 months ago

This is interesting. I (probably obviously since I have not implemented this) am not a ZK user.

A few questions for you:

  1. Would it work for you to just have the filename be set by the first [\d_]* chars (explicitly not - chars) of each file in the notes directory? eg, the id for 202405022227-some-note-a-modifyed.md would be 202405022227 or the id for 20240502_01-some.md be 20240502_01? I could imagine that simplifying the implementation.
  2. Assuming the answer to that is yes, you'd also want the typeahead to work on the some-note-a part of the note, correct?
  3. Have you looked into writing a VS Code task that would create new files? eg, see this post: https://stackoverflow.com/questions/60990175/vs-code-create-file-inside-the-current-directory-of-the-editor - to me this seems safer than allowing arbitrary code execution via the extension.
Liqiduan commented 5 months ago

@kortina

  1. Yes, there is not reason to put that 'uniqueId' in the middle of filename. I think in lot of case that is correct. As I thought, the reason that ZK user only use the unique ID as link, is for change the filename without modify the link. And that will work anywhere without any "auto change link" tool. But pepole may have different way to construct that ID, for example someone would like using 202405022227-note-a.md as base, and append some char for the addtional note like 202405022227a1-note-a.md. That is mainly for "create a knowledge branch", and these note can be obviously sort and put after the note that being addtionly comment. So the pattern [\d_]* is a good start point for ZK starter, but soon they will make is different.

  2. Yes, but some point need to be claim. I think it will help to use some-note-a-modifyed to trigger an auto complete of link [[202405022227]]. Althought here users use some-note-a-modifyed trigger an complete, but they don't want to generate a link like [[202405022227-some-note-a-modifyed]]. So just for trigger complete, I think that is very helpful. And also I think showing Some Note A Modifyed as the brief describe in suggest will be helpful.

  3. Sorry, I am just a starter for vscode extension develop. So, I don't thinking about how to create file in extension before. I am agreed with that, execute any code from user input in extension is very dangerous. But for an IDE extension, that may be save. Users konw what they do, and the extension has the same access right as the IDE. So, it's seems that the user will not, and the extension can not, do something harmful.