Skip to content

Remove heading settings (levels) from core/heading #20213

@ghost

Description

Hey,

I need to remove the heading settings for a project, I assume that is best done using filters?

Using this guide here: https://developer.wordpress.org/block-editor/developers/filters/block-filters/#editor-blockedit it's clear how to add panels to the existing settings, however, it doesn't say anything about removing an existing panel from the inspector.

I have tried something like that to see if existing settings can be changed:

const { createHigherOrderComponent } = wp.compose;
const { Fragment } = wp.element;

const withInspectorControls = createHigherOrderComponent( ( BlockEdit, HeadingToolbar ) => {
	return ( level, setAttributes, props ) => {
		return (
			<Fragment>
				<BlockEdit { ...props }>
					<HeadingToolbar
						minLevel={ 1 }
						maxLevel={ 1 }
						selectedLevel={ level }
						onChange={ ( newLevel ) =>
							setAttributes( { level: newLevel } )
						} />
				</BlockEdit>
			</Fragment>
		);
	};
}, 'withInspectorControl' );

wp.hooks.addFilter( 'editor.BlockEdit', 'core/heading', withInspectorControls );

However, this just gives me a blank block.

I would really appreciate some help with this.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions