breadcrumbs icon indicating copy to clipboard operation
breadcrumbs copied to clipboard

breadcrumbs dataview note should support dataviewjs

Open HananoshikaYomaru opened this issue 3 years ago • 7 comments

dataviewjs can do advanced manipulation. If dataview query is supported, dvjs should be supported as well.

HananoshikaYomaru avatar Feb 07 '22 12:02 HananoshikaYomaru

I don't think there is a simple way to do this... The Dataview API doesn't even expose a way to run regular WHERE queries, so a full dvjs snippet is probably less likely. I'm constrained by what the API can do, you see?

SkepticMystic avatar Feb 12 '22 06:02 SkepticMystic

Isn't it possible to just directly execute that dataviewjs block as js code? Or will it not pick up the dv api calls then, in which case you might be able to pass it onto the js execution engine

HEmile avatar Feb 12 '22 07:02 HEmile

I don't think it will recognise what dv is. I guess it depends what context the code is executed in? But the console doesn't recognise dv, for example, so it won't work on a global scope

SkepticMystic avatar Feb 12 '22 07:02 SkepticMystic

I don't know if this works. I can write normal js code in dvjs codeblock. Can I call a breadcrumb API in the dvjs codeblock to update the breadcrumbs? Then I can use both dvjs and breadcrumbs.

But for sure the dvjs file must be able to run in background.

HananoshikaYomaru avatar Feb 12 '22 08:02 HananoshikaYomaru

@SkepticMystic @HEmile I think the dv in dvjs codeblock is the same as the getAPI() exposed by the dataview. is it possible to run a regex to replace every dv in the codeblock by getAPI() and then pass to js execution engine?

HananoshikaYomaru avatar Feb 12 '22 12:02 HananoshikaYomaru

@HananoshikaYomaru I don't know if you've seen this message yet, but I've exposed an API you can use in dvjs blocks: https://discordapp.com/channels/686053708261228577/855181471643861002/942003316123119646

SkepticMystic avatar Feb 12 '22 13:02 SkepticMystic

@HananoshikaYomaru I think you'd be able to set a variable called dv to getAPI() to ensure the javascript would recognize it. At least that's how it works in other languages, I've never done this in Javascript.

HEmile avatar Feb 14 '22 08:02 HEmile

Note, there's a Dataview API method called executeJS that looks promising. I need to see if it's a superset (can execute regular dv queries as well), or if I need a way to specify. Also, what shape does it return?

See Discord thread for context: https://discord.com/channels/686053708261228577/1014259487445622855/1223887591229886474

SkepticMystic avatar Mar 31 '24 10:03 SkepticMystic

After more investigating, executeJS doesn't do what I expected. It does more than just run the DVJS query, it needs something to render the results into. For that reason, I don't intend to implement around that. If they expose an API to just get the results, I'll reopen this!

As mentioned in a previous comment, the BC API can be used in a DVS codeblock, so atleast there's an integration in that direction

SkepticMystic avatar Apr 06 '24 15:04 SkepticMystic