You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to have common functions for common tasks. I have found it's possible with customJS.
I want to be able to do $=customJS.my.get_duration(), that would
dv = app.plugins.plugins.dataview.api
get_duration() {
var duration = get_my_duration()
return this.dv.el("code", duration)
}
, currently, app.plugins.plugins.dataview.api is an instance of DataviewApi, while .el() method is only available in DataviewInlineApi.
Therefore I found I can achieve dataview-native Duration rendering by calling customJS.my.get_duration(dv), to pass an instance of DataviewInlineApi into my function. Otherwise I'd have to spam $=dv.el("code", customJS.my.get_duration()) which is bad.
upon further lurking, I've found a workaround
dv = app.plugins.plugins.dataview.api
get_duration() {
var duration = get_my_duration()
duration = duration.shiftToAll().normalize()
duration = this.dv.luxon.Duration.fromObject(Object.fromEntries(Object.entries(duration.toObject()).filter(([, quantity]) => quantity != 0)));
var result = duration.toHuman()
return `<code>${result}</code>`
}
Every step in developing using dataview is painful, stuff just acts randomly, for no obvious to me architectural reasons.
when there's inline property on the line, inline render doesn't work; inline render can't seem to reference text of current line/paragraph, at least I haven't found it; block data is refreshed, yet inline data does not; DQL is ....; arrays are magical and I always need to be thinking in which state current array is, "easiness" of arr.file.name implicit mapping magic (magic is always bad) does not outweight complications like result.concat(this.dv.array([item])); etc etc
Is this the right place to request help accessing DataviewInlineApi, preferably somewhere like app.plugins.plugins.dataview.api.inline or app.plugins.plugins.dataview.apiinline, or even at app.plugins.plugins.dataview.api because that's the "main" interface all the reference manuals are written about.
The text was updated successfully, but these errors were encountered:
It's the right place I reckon, but there is not a whole lot of action currently in this repository.
It's common to pass that instance around. I know Templater uses the same kind of logic, even though I don't why it has arisen as a practive. But for now, I reckon that's the safer option to use, pass the dv as variable.
With CustomJS you could potentially have a common method to set it once for each time you run a script, but you would need to have some fail safe in place, just in case it hasn't been set when you call another method.
I want to have common functions for common tasks. I have found it's possible with
customJS
.I want to be able to do
$=customJS.my.get_duration()
, that would, currently,
app.plugins.plugins.dataview.api
is an instance ofDataviewApi
, while.el()
method is only available inDataviewInlineApi
.Therefore I found I can achieve dataview-native Duration rendering by calling
customJS.my.get_duration(dv)
, to pass an instance ofDataviewInlineApi
into my function. Otherwise I'd have to spam$=dv.el("code", customJS.my.get_duration())
which is bad.Every step in developing using dataview is painful, stuff just acts randomly, for no obvious to me architectural reasons.
Is this the right place to request help accessing DataviewInlineApi, preferably somewhere like
app.plugins.plugins.dataview.api.inline
orapp.plugins.plugins.dataview.apiinline
, or even atapp.plugins.plugins.dataview.api
because that's the "main" interface all the reference manuals are written about.The text was updated successfully, but these errors were encountered: