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

Missing documentation on hooks for Gutenberg metaboxes #21698

Closed
matthewmcvickar opened this issue Apr 17, 2020 · 3 comments
Closed

Missing documentation on hooks for Gutenberg metaboxes #21698

matthewmcvickar opened this issue Apr 17, 2020 · 3 comments
Labels
[Feature] Extensibility The ability to extend blocks or the editing experience [Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@matthewmcvickar
Copy link

matthewmcvickar commented Apr 17, 2020

I am trying to extend/alter the functionality of the 'Post Excerpt' metabox in Gutenberg and cannot find documentation or suggestions on how to do this or a clear status of whether it is possible. I have extensively searched issues and PRs here, checked the Gutenberg developer handbook, and searched Stack Overflow, but have not found any answers. Can anyone point me in the right direction?

Where I've looked, and what I've found:

What am I missing?

(Specifically, the changes I want to make to the 'Post Excerpt' metabox are: 1) add a brief instruction about keeping the word count around 20 for the excerpt, 2) add a live word counter to the excerpt editor, so that writers are reminded to keep things brief in their excerpts.)

@talldan
Copy link
Contributor

talldan commented Apr 20, 2020

@matthewmcvickar It doesn't look like this input can be extended, but it seems like it would be possible to replace it with something else.

A new panel can be added to the document settings using the appropriate slot:
https://developer.wordpress.org/block-editor/developers/slotfills/plugin-document-setting-panel/

And the existing panel can be removed with the following code snippet:

wp.data.dispatch( 'core/edit-post' ).removeEditorPanel( 'post-excerpt' );

@talldan talldan closed this as completed Apr 20, 2020
@talldan talldan added [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Help Request Help with setup, implementation, or "How do I?" questions. labels Apr 20, 2020
@alkah3st
Copy link

alkah3st commented Feb 8, 2021

Why is it possible to hook into and extend the Featured Image metabox in Gutenberg but not the Post Excerpt metabox?

For example, I can do this to change the instructions with the Featured Image:

var el = wp.element.createElement;

function wrapPostFeaturedImage( OriginalComponent ) { 
	return function( props ) {
			return (
					el(
							wp.element.Fragment,
							{}, 
							'',
							el(
									OriginalComponent,
									props
							),
							'The featured image is used throughout the site to show a thumbnail representing the post.'
					)
			);
	} 
} 

wp.hooks.addFilter( 
	'editor.PostFeaturedImage', 
	'wpx/wrap-post-featured-image', 
	wrapPostFeaturedImage
);

Why do we have to replace the entire Post Excerpt metabox to achieve the same with it?

@ibes
Copy link

ibes commented Apr 12, 2022

Any wise person who can help there?

This is also a limitation that bothers me with Gutenberg.
And I don't know if it is an architectural limitattion or just a knowledge limitiation that I can learn to overcome.

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 [Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

4 participants