Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding reusableBlock to the supports block configuration #4722

Closed
fastlinemedia opened this issue Jan 28, 2018 · 12 comments
Closed
Assignees
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Extensibility The ability to extend blocks or the editing experience

Comments

@fastlinemedia
Copy link

Issue Overview

My apologies if this is already doable but I didn't see it in the documentation. I don't feel like converting a block I'm working on to a reusable block makes sense.

Would it possible to get reusableBlock added to the supports block configuration so we can disable saving as a reusable block for our blocks?

This block also has useOnce set to true, so maybe another solution would be to remove converting to a reusable block for useOnce blocks.

@gziolo gziolo added the [Feature] Extensibility The ability to extend blocks or the editing experience label Jan 29, 2018
@gziolo
Copy link
Member

gziolo commented Jan 29, 2018

@mtias, technically it is an easy task. The question is if we should add this? I don’t see reasons to not do it.

@gziolo gziolo added the [Feature] Block API API that allows to express the block paradigm. label Feb 1, 2018
@gziolo
Copy link
Member

gziolo commented Feb 5, 2018

Pinging also @noisysocks as he implemented most of the logic for the reusable block.

@noisysocks
Copy link
Member

Sounds reasonable and easy to do. Nesting such an attribute under supports eases my one concern which is that this change would increase the surface area of the block registration API.

This block also has useOnce set to true, so maybe another solution would be to remove converting to a reusable block for useOnce blocks.

I don't think we could do this since one might desire a block that should only appear once in a post but that a user can re-use throughout several posts, e.g. a 'post header' block, a 'google analytics block', etc.

@fastlinemedia
Copy link
Author

Thanks! Getting useOnce under supports sounds good to me.

@mtias
Copy link
Member

mtias commented Feb 9, 2018

Sounds fine to me. Can go with reusable: false default to true

@mtias
Copy link
Member

mtias commented Feb 27, 2018

I'm having second thoughts here. Once we have nesting, making a block non-reusable doesn't make much sense. It'd be trivial to create a "container" block, add the non-reusable block to the container, and make the container reusable.

@noisysocks
Copy link
Member

That's a really good point, @mtias.

@aduth: How does useOnce work when nested within a container block?

@fastlinemedia: Could you please describe your use case for this functionality in a little more detail? What block are you building? Why does it not make sense for one to make it reusable?

@fastlinemedia
Copy link
Author

@mtias @noisysocks thanks for the follow up on this!

I'm not quite following the example for why it wouldn't make sense to make a block non-reusable but I don't think it's a huge issue for what I'm trying to do if that's the case.

I've been working on a block for switching between Gutenberg and Beaver Builder. So far, this is what we have...

https://www.dropbox.com/s/nc0pnn70ry07g8v/beaver-builder-block.mov?dl=0

I don't really think it makes sense for that block to be reusable (definitely should be useOnce though), however, I don't think it's going to hurt anything if it is turned into a reusable block.

I'll go ahead and close this one out. Thanks again!

@mtias
Copy link
Member

mtias commented Mar 1, 2018

@fastlinemedia thank you for the discussion! I think honoring useOnce here would make sense. My point was that, since we have nested block support, you could imagine a user adding a Columns block on which they insert your non-reusable block, and making the column group reusable — which effectively means your non-reusable block is being reused. Does that make more sense?

@fastlinemedia
Copy link
Author

@mtias no problem and thanks for explaining it further! That makes perfect sense.

@noisysocks
Copy link
Member

@fastlinemedia: FYI, this came up again in #5941 and there's now an open PR which adds the functionality you requested: #5970

@fastlinemedia
Copy link
Author

@noisysocks thanks for the heads up! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Extensibility The ability to extend blocks or the editing experience
Projects
None yet
Development

No branches or pull requests

4 participants