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
Is your feature request related to a problem? Please describe.
I'd love to be able to target different inline fields based on their values, not just their keys. Currently, it is not possible to do so, and CSS does not support selecting based on inner-text.
Describe the solution you'd like
I'd like to add data-dv-value attributes to the inline field spans, so that I can target them with CSS like so:
Describe alternatives you've considered
An alternative that I considered is to just create different keys & set them to "true", but that's a bit messy & requires a lot of manual re-work (e.g., setting locked to false then also unlocked to true).
Additional context
I tried updating the dataview plugin in my own vault to include these lines and it seems to work without issues!
toDOM() {
// A large part of this method was taken from replaceInlineFields() in src/ui/views/inline-field.tsx.
// It will be better to extract the common part as a function...
const renderContainer = createSpan({
cls: ["dataview", "inline-field"],
});
// Block inline fields render the key, parenthesis ones do not.
if (this.field.wrapping == "[") {
const key = renderContainer.createSpan({
cls: ["dataview", "inline-field-key"],
attr: {
"data-dv-key": this.field.key,
"data-dv-norm-key": canonicalizeVarName(this.field.key),
},
});
renderCompactMarkdown(this.app, this.field.key, key, this.sourcePath, this.component, true);
const value = renderContainer.createSpan({
cls: ["dataview", "inline-field-value"],
// ✨ New stuff here
attr: {
"data-dv-key": this.field.key,
"data-dv-value": this.field.value
},
});
renderValue(this.app, parseInlineValue(this.field.value), value, this.sourcePath, this.component, this.settings, false, undefined, undefined, true);
this.addKeyClickHandler(key, renderContainer);
this.addValueClickHandler(value, renderContainer);
}
else {
const value = renderContainer.createSpan({
cls: ["dataview", "inline-field-standalone-value"],
// ✨ And also here
attr: {
"data-dv-key": this.field.key,
"data-dv-value": this.field.value
},
});
renderValue(this.app, parseInlineValue(this.field.value), value, this.sourcePath, this.component, this.settings, false, undefined, undefined, true);
this.addValueClickHandler(value, renderContainer);
}
return renderContainer;
}
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I'd love to be able to target different inline fields based on their values, not just their keys. Currently, it is not possible to do so, and CSS does not support selecting based on inner-text.
Describe the solution you'd like
I'd like to add
data-dv-value
attributes to the inline field spans, so that I can target them with CSS like so:Describe alternatives you've considered
An alternative that I considered is to just create different keys & set them to "true", but that's a bit messy & requires a lot of manual re-work (e.g., setting
locked
tofalse
then alsounlocked
totrue
).Additional context
I tried updating the dataview plugin in my own vault to include these lines and it seems to work without issues!
The text was updated successfully, but these errors were encountered: