-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Editor: Unify PluginMoreMenuItem API between post and site editors #60778
Conversation
Size Change: +125 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Flaky tests detected in 1f764b6. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8718607577
|
@@ -74,7 +67,7 @@ export default compose( | |||
return { | |||
as: ownProps.as ?? MenuItem, | |||
icon: ownProps.icon || context.icon, | |||
name: 'core/edit-site/plugin-more-menu', | |||
name: 'core/editor/plugin-more-menu', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems there will be a behavior change, a plugin that included code with a more menu item only for the site editor, will now also load that more menu on the post editor. Maybe it is an acceptable change but it is something we should document on the dev not that is planned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this will be the same for all the extensibility APIs. It has been discussed in #59985 we think it's fine but we'll be monitoring feedback.
@@ -120,7 +120,7 @@ export default function MoreMenu( { showIconLabels } ) { | |||
</MenuGroup> | |||
<ModeSwitcher /> | |||
<ActionItem.Slot | |||
name="core/edit-site/plugin-more-menu" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to have two slots here one with core/editor/plugin-more-menu and another one with the old one core/edit-site/plugin-more-menu in case a plugin is using the old "core/edit-site/plugin-more-menu" directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not personally, I'm for unifying the editors entirely including their extensibility APIs as one editor will ultimately replace the other.
*/ | ||
import deprecated from '@wordpress/deprecated'; | ||
|
||
export function normalizeComplementaryAreaScope( scope ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function ensures there's no breaking change for people calling these selectors/actions in their code base. I initially thought the interface package is entirely private but it turns out that folks can access its actions and selectors unfortunately.
9fc7027
to
64b0d49
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some tests with common third-party plugins things worked well.
I also tried some variations of the following test code:
var __ = wp.i18n.__;
var el = wp.element.createElement;
var PanelBody = wp.components.PanelBody;
var PluginSidebar = wp.editSite.PluginSidebar;
var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
function MyPluginSidebar() {
return el(
PluginSidebar,
{
name: 'my-sidebar',
title: 'My sidebar title',
icon: moreIcon,
},
el(
PanelBody,
{},
__( 'My sidebar content' )
)
);
}
wp.plugins.registerPlugin( 'toto', { render: () => wp.element.createElement( MyPluginSidebar ) } );
Things tested well, so I think we can merge this PR 👍 Thank you for addressing the issues raised.
As an aside, I think it makes sense to have wp.editor.PluginSidebar. But I guess you are planning that as a follow-up.
6b5914e
to
2bcf035
Compare
Looks like this PR impacted "type" metric in the site editor. Looking into it. |
Related #52632
Similar to #59985
What?
This PR unifies the
PluginMoreMenuItem
between the post and site editors allowing plugin authors to use the same code to load their plugins regardless of the context of the editor.How?
@wordpress/edit-post
and@wordpress/edit-site
to.@wordpress/editor
Testing Instructions
You should be able to paste something like the following in both post and site editors and have the button show up in the more menu.