I like to build a field plugin where I read the value of an existing field “ISBN” make an isbn api call and populate the fields “title”, “publisher”, “author” ect.
I do not know how to access the data outside of the plugin.
AI suggestet using this.$store, but it is undefined inside the plugin
here is my basic script:
panel.plugin("me/isbnfetcher", {
fields: {
isbnfetcher: {
props: {
label: String
},
methods: {
updateField(field, value) {
this.$root.$store.dispatch("content/update", {
field: field,
value: value
});
},
fetchMeta() {
console.log("this.$store:", this.$store);
const isbn = this.$store.getters["content/values"].isbn;
}
},
template: `
<k-field :label="label">
<k-button @click="fetchMeta">Metadaten laden</k-button>
</k-field>
`
}
}
});