Skip to content

Provide a way to remove/modify text alignment for core blocks #24616

@jakewhiteley

Description

@jakewhiteley

Is your feature request related to a problem? Please describe.
As someone who uses WordPress to provide websites for clients, I need to be able to restrict the type of content a user can add via Gutenberg. This could be due to design reasons, enforcing a style guide for editors, or simply because the theme does not support alignment.

This is directly related to the rationale behind #15160 .

Describe the solution you'd like
Either include alignment in the upcoming experiemental-theme.json, or provide a robust (and documented) way to modify the alignment control on all core blocks - without having to deregister a core block, and register a customised version as a replacement.

It should allow a developer to specify which alignments are supported, or completely disable alignment.

the blocks.registerBlockType feels like a good candidate as it already can be used to disable alignment for some core blocks.

Describe alternatives you've considered
I tried the following:

window.wp.hooks.addFilter('blocks.registerBlockType', 'my-theme/hide-alignment', function(settings, name) {
	return Object.assign({}, settings, {
		supports: Object.assign({}, settings.supports, {align: false})
	})

	return settings
})

But this only removes alignment controls on blocks like core/embed, it does not remove text alignment on core/heading or core/paragraph.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CustomizationIssues related to Phase 2: Customization efforts[Feature] Block APIAPI that allows to express the block paradigm.[Type] EnhancementA suggestion for improvement.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions