-
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
Close button: extensibility in post editor #22323
Conversation
Size Change: +235 B (0%) Total Size: 832 kB
ℹ️ View Unchanged
|
|
||
const { Fill, Slot } = createSlotFill( name ); | ||
|
||
const MainDashboardButton = Fill; | ||
MainDashboardButton.Slot = Slot; | ||
MainDashboardButton.slotName = name; | ||
|
||
export const CloseButton = () => { | ||
export const CloseButtonSlot = ( { children } ) => { |
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.
Why not make this MainDashboardButton.Slot
? Is there any place where we would just use the bare MainDashboardButton.Slot
?
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.
Now that you mentioned it - no, we probably don't. :) I refactored this in 7d1b948. I had to separate out the assignment though because the linter was complaining otherwise:
React Hook "useSlot" is called in function "MainDashboardButton.Slot" that is neither a React function component nor a custom React Hook function
Likely because it wasn't detected as valid component name for some reason. 🤔
@@ -155,3 +155,4 @@ export { default as PluginPostStatusInfo } from './components/sidebar/plugin-pos | |||
export { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel'; | |||
export { default as PluginSidebar } from './components/sidebar/plugin-sidebar'; | |||
export { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item'; | |||
export { default as __experimentalFullscreenModeClose } from './components/header/fullscreen-mode-close'; |
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.
Can this component be shared between edit-site
and edit-post
?
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.
We considered that in #20989 (comment) but decided not to do it for now.
@@ -7,12 +7,14 @@ the editor in fullscreen mode. | |||
|
|||
```js | |||
import { registerPlugin } from '@wordpress/plugins'; | |||
import { __experimentalMainDashboardButton } from '@wordpress/edit-site'; | |||
import { |
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's great that there are docs here for this, just had a request for this!
Looks like the file just needs to be added to the toc.json file for it to show up in the block editor handbook.
I've made a PR to publish them - #27317 - if you get a chance to review, @vindl.
edit: don't worry about the review, decided to admin merge it.
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 was afk for a couple of days so just got to this now. Thanks for the update @talldan!
Description
This is a follow up PR to #22001 and #22179. It's addressing the first part of #20929 issue.
The close button slot introduced for site editor in #22001 is expanded to cover the post editor too. The button can now be replaced in a similar fashion for all editor instances.
MainDashboardButton
has been moved to interface package so that the same slot can be reused inedit-post
andedit-site
.How has this been tested?
If you want to replace the whole component:
If you just want to customize the icon:
In both cases open check the post editor and site editor and make sure that the custom components are shown there.
Screenshots
Types of changes
Breaking change (fix or feature that would cause existing functionality to not work as expected)
Checklist: