collective / volto-hydra

A volto addon to let you edit content in realtime when you have many frontends written in any framework
1 stars 2 forks source link

restrict all block types except text & image on add #98

Closed MAX-786 closed 2 months ago

MAX-786 commented 2 months ago

Fixes #70

Since, we only support image & text blocks, so restricting every other block type.

djay commented 2 months ago

@MAX-786 This isn't really a fix for #70 . A proper fix means changing the volto settings which has a registry of which block types are allowed and not allowed. This can be changed now using an env variable so no need to for this hack I think. but the proper fix is for this setting to be passed from the frontend to the admin UI on the bridge init so the frontend dynamically tells the backend what it can handle. I think that's not so hard to do?

This means that if the frontend wants to add support for more blocks, like video, then they can easily

MAX-786 commented 2 months ago

@MAX-786 This isn't really a fix for https://github.com/collective/volto-hydra/issues/70 .

Yeah i mentioned a comment in that issue too that this is just to keep ppl away from using blocks which are not yet supported.

This can be changed now using an env variable so no need to for this hack I think.

Oh i didnt knew, is it documented somewhere ? will be really helpful. I did my own lil research but just found this config edit approach to restrict blocks.

but the proper fix is for this setting to be passed from the frontend to the admin UI on the bridge init so the frontend dynamically tells the backend what it can handle. I think that's not so hard to do?

@djay yes but making changes in the registry, doesn't it require rebuild of the whole volto site? let me know if I am getting it wrong, i will look into more .

djay commented 2 months ago

@MAX-786 as discussed in the meeting. I might be wrong it can be changed by Env variable but settings can be dynamically changed so essentially we are making an API to make changes to this via the bridge init. For now just the list of allowed blocks but later we can allow more like schema changes.

MAX-786 commented 2 months ago

@djay Now, i extented the init bridge to take an options obj as an argument and integrators can optionally pass a list of allowed blocks like ,

const brige = initBridge("http://localhost:3000", {allowedBlocks: [ "slate", "image", "video"]});

I updated the readme too.

MAX-786 commented 2 months ago

@JeffersonBledsoe if possible can you just give it a go and see if i am doing this how it's supposed to be done? then we will merge it

djay commented 2 months ago

@MAX-786 if it results in the add menu only having those blocks then it's working isn't it?

MAX-786 commented 2 months ago

@djay Yepp, oki lets merge it then