field-plugin icon indicating copy to clipboard operation
field-plugin copied to clipboard

Define and read space level settings

Open tomoglavas opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe.

I am building a plugin that needs to use external api, and needs an api key added for that. Currently, the only way I can see of doing that is to define it as a plugin option in the field-plugin.config.json file. That means that the api key will need to be added in plaintext, to each instance where it is defined in a block. The interface below is what I mean, for context.

Screenshot from 2024-12-19 14-08-31

If we need to change the api key to a new one at some point in time, that means going through all the block definitions and finding all the instances where this custom field plugin is used and manually updating the values. This is obviously error prone and less than ideal.

Describe the solution you'd like

After installing the plugin to a space, I can see there is a section in the space level settings for the plugin. See screenshot:

Screenshot from 2024-12-19 14-01-59

This implies I should be able to read these space level settings from within the plugin, but I don't see any examples of that, no mention in the documentation or in @storyblok/field-plugin code.

Ideally, we would be able to define required settings for the plugin to work, the interface type for each setting (ie, text/number/boolean/select options) and have the setting values automatically provided to the plugin instance at runtime.

Describe alternatives you've considered

Currently, settings are copied manually to each instance where plugin is added to a block.

tomoglavas avatar Dec 19 '24 13:12 tomoglavas