blacksmithgu / obsidian-dataview

A data index and query language over Markdown files, for https://obsidian.md/.
https://blacksmithgu.github.io/obsidian-dataview/
MIT License
7.06k stars 414 forks source link

Embedded notes miss link to note #2303

Open Gnopps opened 7 months ago

Gnopps commented 7 months ago

What happened?

Using Dataview v0.5.64 or below and embedding a note using dataviewjs, using dv.el("p", "![[" + file.name + "]]") there is a button to click to take you to the embedded note. The same behaviour is there if you embed a note not using Dataview, i.e. just linking in the note using ![[note]]. Example below of an embedded note (using the JS-code provided below) and the link-button.

image

Starting with Dataview v0.5.65, this button to open the embedded note is gone. The button is still there when embedding notes manually but not when using dataviewjs. I suspect this bug has come about with the embed-rendering fixes that @GottZ did in #2266, #2261, or #2265 ?

So bug is that the "Open link"-icon is missing and needs to be restored.

DQL

No response

JS

let meetings = dv.pages(`"${dv.current().file.folder}" and #meeting`)
meetings = meetings.sort(k => k.date.path.split("/").last(), 'desc')
for (let meeting of meetings){
dv.el("p", "![[" + meeting.file.name + "]]");
}

Dataview Version

0.5.66

Obsidian Version

1.5.12

OS

Windows

GottZ commented 7 months ago

good catch. the change I did involved replacing a deprecated API with the "to be used" one (as suggested by obsidian.md docs itself) I'll dig a little. you are right, this should be fixed.

image

issue is easily reproducible.

image

````dataviewjs
const file = dv.current().file;
const {path, folder, name, link, ext} = file;
dv.span("```json\n"+ JSON.stringify({path, folder, name, link, ext}, null, "  ") +"\n```")

![[test nested]]

dv.span("![[test nested]]")


[this](https://github.com/blacksmithgu/obsidian-dataview/pull/2266/files#diff-cd8c0af627317c05d77557aea643940ce0f9c713584c5b6ab096868c52ddff08L21-R22) and [this](https://github.com/blacksmithgu/obsidian-dataview/pull/2266/files#diff-cd8c0af627317c05d77557aea643940ce0f9c713584c5b6ab096868c52ddff08L40-R42)
this is the essence of the fix, so I suspect undefined behavior in obsidian itself.

Update:
I've now embedded this note inside another note and noticed the same behavior.
apparently when embedding notes with dvjs, the link will not even be added recursively.
Gnopps commented 5 months ago

@GottZ do you know if this has been reported to Obsidian? If not I'm happy to do it, though I don't really know what to reference when reporting.