Link Lens - relationships between links at block level (help needed with refactoring!)

I created a plugin which is heavily inspired by the backlinks filtering of Roam Research (I wrote my master’s thesis thanks to that fucntion). I strongly needed it since 2023 and I explained the reasons in this post and this post.

It suits my workflow where I “tag” the paragraphs or bullet points of my notes with links that refer to specific concepts. With this plugin I am able to find every block that contains specific links, hence every block that refers to specific concepts. The best part is that the plugin tells you which other links are contained in the blocks that you found, so that you can start your search without knowing what you are looking for. You just need to want to see which concepts are related to a specific one.

I hope that this can fits other workflows, too.

I didn’t upload it to the community plugins becase I have no idea how to code. This entire plugin has been vibe coded with AI (check the README). I would like a lot to publish it but it needs some serious refactoring and I’m not able to implement the Plugin guidelines. If someone of you wants to adopt this little monster of a code and make it shine (maybe because you actually need it) please do it! You can contact me on Telegram at @mortacci

Here are some improvements that can be made (you find it in the README, too):

  • CSS code is a complete mess with plenty of repeated classes and it is inside main.ts. The external css file is not used (I think).
  • Custom sorting of results preview (by name, date of creation, date of last edit, ecc.).
  • Add the possibility that, if searching for a term that doesn’t exist as link, this search is performed as a simple regex search, looking for items that contains an exact match to that term.
  • Add the possibility to search for tags. I don’t use tags so much in my note-taking workflow, so I didn’t implement this in this initial version.
  • Add a command to open the search panel with the current note already selected as search term (and start the research).
  • Add the possibility to customize the research by adding the search terms with AND, OR or NOT operators, and the UI should be re-made accordingly (the container of the search terms tagsContainer should be divided in three sections, one for each operator). It can work like this:
    • if you click a Related link it is added with AND operator
    • if you Shift-click a Related link it is added with OR operator
    • if you Alt-click a Related link it is added with NOT operator

Plugin link: GitHub - Taccimor/linklens: A plugin for Obsidian to find relationships between links and/or properties at block level.

I just uploaded a new release adding most of the features I suggested (including refactoring). I don’t think I will modify the code further.

I wrote some known issues, whoever would like to help is welcome!

Fellow “viber” here.

I saw value in the idea as related ideas are often on the same block (paragraph or line).

I often create blockID’s for these too.

I was thinking I could do something with it maybe to get more out of it to add to my former workflow.

For now, here is 0.3.0:

Fixed:

  • No longer using cached sections but backlinks (or rather: resolvedlinks). Now we’re getting back those missing results.
  • Fixed date filtering for ASC and DESC. Added date support for all ISO dates (although didn’t test them such as YYMMDD or YY-MM-DD and others).
  • Not allowing AND/OR/NOT for a single file: starting search for the latter two led to highly taxing the cache, leading to stale cache issues or similar anomalies later on (I have a huge vault and many backlinks so I saw this).
  • Added plain text search support. Sometimes we forget to add the link…
  • Added various configged stuff like allowing to exclude SYSTEM and other folders, only allowing certain property fields (and values) in the mix, etc.
    • User dates frontmatter fields need to be added, such as ‘date modified’, or ‘created’, etc. but system dates are added by default.
    • Add filters for properties: add ‘tags’, ‘status’, etc. to show only those, otherwise too many unimportant properties can hog the space.

NOT is achieved through Ctrl/CMD+Shift+Enter/Click, not Alt.
You add a file for OR via Shift+Enter/Click, and normal AND with Enter/Click.

Test it and try adding to it if you will.
This is for Obsidian use:
Removed.

I’m sure there are some issues and bugs left in it but the logic seems largely right now.

Other people can try it as well. I added a data.json.bak for users to see what can be added as settings and how if unsure.

EDIT.

Added highlights to normal search, regex support and history (default: true) to normal search.

EDIT 2.
Fixed logic of all entries and event handlers properly handling AND, OR and NOT removing any possibility of vault crash on any inadvertent use of OR or NOT on addition of a first term (whether by initated via backlinks or normal search).

  • Meaning: even if you – by mistake – press Shift (or Ctrl/Cmd+Shift) on an Enter or Click, you will not get anything other than the exact search result of a picked search. You cannot get the inverse (full vault with all blocks) search result.

Stale stales are removed by proper re-initialization.

Kept version at 0.3.0 (too lazy to edit that).

@Mortacci I forgot the .ts and its friends (for developing only):
Removed.

You got help (which is where I’m moving this) and didn’t even take the time to type in a word of…anything. Bravo.

Hey fellow viber! I saw your message only yesterday but I’ve been very busy and I didn’t even download your code! I’m sorry, I wanted to take time to answer fully!
I appreciate A LOT your help, I didn’t expect anyone to actually try to improve the code. Few days ago I sent version 0.0.2 to approval as community plugin and I’m in the process of applying some changes that they are requesting. So I want first to get the plugin approved (I hope) and then I will have to merge the two versions, to be sure that version 3 can be approved too. If you have telegram you can contact me at @mortacci and we can coordinate for when I’ll look at your code

1 Like

0.0.2 is faulty, all around. I’m surprised the team would even consider it being applicable.