[Bug] fieldModifier doesn't work properly when concat'ed with string #51
caasion
started this conversation in
Tips and Tricks
Replies: 1 comment 1 reply
-
Hi this is not a bug, this is due to the fact that fieldModifier returns an HTMLElement (this is what is expected from the dv.table argument). one way to achieve what you want is to create a concat function that will return an htmlElement containing 2 children:
example: const {fieldModifier: f} = this.app.plugins.plugins["metadata-menu"].api;
const concat = (text, field) => {
const wrapper = dv.el("div", "");
wrapper.setAttr("style", "display:flex");
const prefix = document.createElement("span");
prefix.setAttr("style", "margin-right: 1em");
prefix.setText(text);
wrapper.appendChild(prefix);
wrapper.appendChild(field);
return wrapper
}
dv.table(["Field1", "Field2"],
await Promise.all([dv.current()]
.map(async p => [
await f(dv, p, "field1"),
concat("Field 2:", await f(dv, p, "field2"))
])
)
) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If I try to concat a fieldModifier field with some string, it ends up in the wrong place: outside the table.
Query:
Beta Was this translation helpful? Give feedback.
All reactions