I’m trying out making my first custom view and trying to test out what’s possible.
I’d like to make a link to a note, just like I would do from another note.
I tried passing a simple markdown link to render - Developer Documentation
And it seems to correctly render the html but it’s neither clickable nor does the hover preview work.
Having a look at the html in the Obsidian Debugger, it’s identical to that of an identical link if I paste the same markdown into a note.
That’s further proven by the fact that if I copy the html rendered by my custom view’s call to render… And paste it into a note… Both clicking and preview work.
However, if I try to use that in a Custom view, then it displays identically, but as I said above, it’s neither clickable nor hoverable.
Note that I’ve tried both creating that element by hand as well as using the markdown renderer described above. They produce the same result.
It’s interesting because I’ve confirmed that the HTML is definitely identical between my note and my custom view. I’ve triple checked this by even going into the Obsidian debugger, and copying and pasting the link HTML between a note and my custom view.
E.g. If I take what’s not working in my custom view and paste it into the live debugger of my note, it works immediately.
What’s going on here?
I can clearly see that the mouseover listener isn’t set in a custom view for whatever reason which helps explain at least the hover part not working.
I can’t seem to find any documentation on this except the fact that supposedly the hover portion of it is handled by Page preview - Obsidian Help which doesn’t address custom views.
But even if I pretend for a moment that that is why the preview isn’t working…why isn’t the plain old click working?
Hey, I dont know much about custom view, havent used one yet, but I tried the following method it seems to be working for me, try it out if it works for you.
First I created a separate file to keep the links management part organized :
Now, the place from where you are calling the MarkdownRenderer.render function. Right after that call the above function by passing the same arguments, as you were passing to the render function.
(I havent used the addEventListener listeners properly, will fix it later, let me know if anyone know how to add the event listeners properly.)