Skip to content

Extending AlignmentToolbar Options #27629

Description

@augustuswm

Is your feature request related to a problem? Please describe.

Short: We would like to be able to extend BLOCK_ALIGNMENTS_CONTROLS at runtime.

My apologies in advance if this is already configurable somewhere (or if this is not in the scope of Gutenberg) as I am still getting a handle on the Gutenberg source.

Longer: We currently develop our in house CMS on top of WordPress, and we were looking to extend the default alignment options. From what I can tell we can currently define custom alignment keys in our block registrations (supports.align) or filter existing block registrations to add additional alignment keys. While they are technically functional, these alignments do not have icons or titles in the AlignmentToolbar as they are not present in the BLOCK_ALIGNMENTS_CONTROLS object that is defined in https://github.com/WordPress/gutenberg/blob/master/packages/block-editor/src/components/block-alignment-toolbar/index.js

Describe the solution you'd like

A filter we could hook with a function that would return the extended BLOCK_ALIGNMENTS_CONTROLS. This filter would then be invoked by the AlignmentToolbar instead of the referencing the BLOCK_ALIGNMENTS_CONTROLS object.

Describe alternatives you've considered

I think this functionality could also be handled by a registration model with a store, but that seems like a lot of extra work. I'm sure there are other options, but I'm not familiar enough with Gutenberg internals to suggest them.

Alternatively we can certainly solve this with a self-built version of Gutenberg, but we prefer to stay with the version distributed with WordPress releases if possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] ExtensibilityThe ability to extend blocks or the editing experience[Feature] LayoutLayout block support, its UI controls, and style output.[Type] EnhancementA suggestion for improvement.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions