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.12k stars 419 forks source link

embed() does not work from inline expressions #2016

Open chaoskcw opened 1 year ago

chaoskcw commented 1 year ago

What happened?

embed does not work from inline expressions, it returns only plain text and not a link or embedded link

= link(" - Notes") works = embed(link(" - Notes")) does not work

Also text manipulation also gets scrubbed to plain text

DQL

= embed(link(" - Notes"))

JS

No response

Dataview Version

0.5.56

Obsidian Version

1.3.7

OS

MacOS

EdualcLaiv commented 1 year ago

I can confirm it still dœsn't work in:

Dataview Version 0.5.64

Obsidian Version 1.4.16

OS Windows 11


Here is a test with an image, in the test vault with no other plugin installed (it works with regular DQL, but not in an inline query):

image


---
img: "[[test.png]]"
---

```dataview
TABLE
embed(link(img)) as Image
WHERE img

= embed(link(this.img))



It dœs the exact same rendering with `img: test.png` instead of `img: "[[test.png]]"`.
sudoexec commented 11 months ago

Me too. I want to embed daily notes using:

`=embed(link(dateformat(date(today), "yyyy-MM-dd")))`

But it only show the daily notes' filename.

Eldresh commented 11 months ago

I would like to add to this that even something like ="![[" + "image.png" + "]]" results in only text being displayed. Or even ="!" + link("image.png"). Something about the inline queries just makes displaying images literally impossible. For example, using a "lens.png" from my current vault, the html renders in edit mode as:

<div class="cm-line">
  <img class="cm-widgetBuffer" aria-hidden="true">
  <span contenteditable="false"></span>
  <img class="cm-widgetBuffer" aria-hidden="true">
  <img class="cm-widgetBuffer" aria-hidden="true">
  <span class="dataview dataview-inline" contenteditable="false">
    <span>
      <span alt="lens.png" src="!Assets/Game Images/Aspects/Things/lens.png" class="internal-embed">lens.png</span>
    </span>
  </span>
  <img class="cm-widgetBuffer" aria-hidden="true">
</div>

And in reading mode as:

<div class="node-insert-event">
  <p>
    <span class="dataview dataview-inline-query">
      <span>
        <span alt="lens.png" src="!Assets/Game Images/Aspects/Things/lens.png" class="internal-embed">lens.png</span>
      </span>
    </span>
  </p>
</div>
davidkopp commented 11 months ago

The cause of this issue seems to be the same as of #1051:

This is because inline queries don't currently use react (which supports inline images) for their rendering; will see if I can get it to work.

Originally posted by @blacksmithgu in https://github.com/blacksmithgu/obsidian-dataview/issues/1051#issuecomment-1112870489

breakid commented 2 weeks ago

As of today, the example posted by @EdualcLaiv, is working for me.

Obsidian Version: 1.7.4 Dataview Version: 0.5.67 OS: Windows 10

dataview_issue_2016

Additionally, given that the img property is already a link, the following works as well: = embed(this.img)

EdualcLaiv commented 2 weeks ago

I confirm, it's working now.

Obsidian Version: 1.7.5 Dataview Version: 0.5.67 OS: Windows 11 (Professionnel) x86_64 — Kernel: WIN32_NT 10.0.22621.4317 (22H2)