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

Add ability to mark block as post content #59290

Closed
fabiankaegy opened this issue Feb 22, 2024 · 4 comments · Fixed by #60068
Closed

Add ability to mark block as post content #59290

fabiankaegy opened this issue Feb 22, 2024 · 4 comments · Fixed by #60068
Assignees
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Feature] Template Editing Mode Related to the template editor available in the Block Editor [Type] Enhancement A suggestion for improvement.

Comments

@fabiankaegy
Copy link
Member

fabiankaegy commented Feb 22, 2024

When the block editing mode is set to template-lock the template is rendered but all the blocks that are within the template have their block editing mode set to disabled.

All except for the post title, post featured image, and post content blocks.

These are hardcoded into a constant here:

const PAGE_CONTENT_BLOCKS = [
'core/post-title',
'core/post-featured-image',
'core/post-content',
];

There are many ciscumstances where a 3rd party block also reads / writes data to the post object. Whether that is a meta field, a taxonomy or any other custom element.

It would be great it there was a way to identify those blocks to get the same treatment as these three blocks.

Proposed solutions

Maybe a block support would make sense here 🤔

{
    "version": 2,
    "name": "namespace/event-location",
    "title": "Event Location",
    "supports": {
        "postContent": true // very open to other names for this
    }
}

The idea would be that a block can flag that it saves something to the post instead of only saving to local attributes.

@fabiankaegy fabiankaegy added [Type] Enhancement A suggestion for improvement. [Feature] Extensibility The ability to extend blocks or the editing experience [Feature] Template Editing Mode Related to the template editor available in the Block Editor labels Feb 22, 2024
@fabiankaegy
Copy link
Member Author

@youknowriad I'd love to get your take on solving this issue with a block support vs a filter / some other approach. Very open to suggestions :)

@Mamaduka
Copy link
Member

Makes sense. Developers should be able to mark blocks that qualify as page content for their projects.

cc @noisysocks

@noisysocks
Copy link
Member

I'm not sure that a block should care too much about the intricacies of post editing in the site editor. Block are pretty foundational after all. They're often used outside of WordPress, even.

I think I'm more inclined to allow customising this list via a filter.

@fabiankaegy
Copy link
Member Author

Thanks for those insights. @noisysocks as per your suggestion I created a PR that adds a filter to allow overwriting the list: #60068

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Feature] Template Editing Mode Related to the template editor available in the Block Editor [Type] Enhancement A suggestion for improvement.
Projects
Development

Successfully merging a pull request may close this issue.

3 participants