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 section on modifying core block options through various options. #35

Open
fabiankaegy opened this issue Apr 19, 2022 · 2 comments
Open

Comments

@fabiankaegy
Copy link
Member

This came up in slack because of a question on how to remove all alignment options from a core block and how to remove the default wide alignment from the core media & text block.

This would be a good topic for both a reference / guide article and a training lesson.

@pdavies88
Copy link
Contributor

@fabiankaegy I am assuming that this Reference should have an example like one of these snippets correct?

import { addFilter } from '@wordpress/hooks';

function modifyMediaTextBlockOptions(settings, name) {
	if (name !== 'core/media-text') {
		return settings;
	}

	return {
		...settings,
		supports: {
			...settings.supports,
			align: false,
		},
	};
}

addFilter(
	'blocks.registerBlockType',
	'modify-media-text-block-options',
	modifyMediaTextBlockOptions,
);

@fabiankaegy
Copy link
Member Author

@pdavies88 Yes exactly :) With this one we will need to be very explicit about the side effects this can create around block deprecations. So we should test the code examples with existing content already on the page :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants