verbb / vizy

A flexible visual editor for Craft CMS
Other
44 stars 8 forks source link

Reusable block library? #222

Open FreekVR opened 1 year ago

FreekVR commented 1 year ago

Question

We're looking into using Vizy for our project, and I've test-driven the plugin, but I am unable to achieve one of our goals:

We want to build a generic block library, where we can re-use Vizy blocks across different Vizy fields with different configs;

For example, imagine we have the following blocks:

We have Entry type A, B, C where we want to show all three -> We would use a Vizy field called "allVizyBlocks"

We have entry type D where I only want to allow the image gallery and disable text input -> We would use a Vizy field called "limitedVizyBlocks" and turn on the "Blocks only" mode for this field.

At this moment I would have to re-define the Image gallery block for the second Vizy field though -- so I am looking for a way to have a single Block definition I can re-use in different restricted contexts. Having a single (type) definition would also help with the fact we use GraphQL for our project, so we want to have only one GraphQL type for this block as well.

Is there any way to achieve this now?

Additional context

No response

engram-design commented 1 year ago

That'd be correct, block types need to be defined per-field at the moment. There's not really plans to associate multiple block types to multiple fields, because that relationship is required for a whole heap of things. We need to be able to determine which block type belongs to which field for example.

FreekVR commented 1 year ago

Thanks for the quick feedback! The closest I've found is using Super Table fields for each block, which allows us to at least re-use a specific combination of fields quickly (we'd still have to redefine the containing Vizy block each time, though, and the layout/UX in the editor isn't ideal)

Another solution for us could be any future progress on conditional fields like in #64 which could open up some options to re-use the same vizy field everywhere and apply some context (entry type)-based conditions per block.

maxstrebel commented 1 year ago

I'd also like to +1 this. Maybe some kind of JSON config that can be shared in multiple fields.

If you want to have a good rich text in a Matrix, Vizy is the only good alternative to NEO at the moment. But when I have multiple elements, where I want to reuse the same rich text, I need to create the same element for each field at the moment. Which is tedious and error prone. Would greatly appreciate.