-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify publish flow between post and site editors
- Loading branch information
1 parent
91ea8fa
commit 5616b5a
Showing
19 changed files
with
576 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
packages/edit-post/src/components/preferences-modal/enable-publish-sidebar.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 12 additions & 80 deletions
92
packages/edit-post/src/components/sidebar/plugin-post-publish-panel/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,15 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { usePluginContext } from '@wordpress/plugins'; | ||
import { createSlotFill, PanelBody } from '@wordpress/components'; | ||
|
||
const { Fill, Slot } = createSlotFill( 'PluginPostPublishPanel' ); | ||
|
||
/** | ||
* Renders provided content to the post-publish panel in the publish flow | ||
* (side panel that opens after a user publishes the post). | ||
* | ||
* @param {Object} props Component properties. | ||
* @param {string} [props.className] An optional class name added to the panel. | ||
* @param {string} [props.title] Title displayed at the top of the panel. | ||
* @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened. When no title is provided it is always opened. | ||
* @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar. | ||
* @param {Element} props.children Children to be rendered | ||
* | ||
* @example | ||
* ```js | ||
* // Using ES5 syntax | ||
* var __ = wp.i18n.__; | ||
* var PluginPostPublishPanel = wp.editPost.PluginPostPublishPanel; | ||
* | ||
* function MyPluginPostPublishPanel() { | ||
* return React.createElement( | ||
* PluginPostPublishPanel, | ||
* { | ||
* className: 'my-plugin-post-publish-panel', | ||
* title: __( 'My panel title' ), | ||
* initialOpen: true, | ||
* }, | ||
* __( 'My panel content' ) | ||
* ); | ||
* } | ||
* ``` | ||
* | ||
* @example | ||
* ```jsx | ||
* // Using ESNext syntax | ||
* import { __ } from '@wordpress/i18n'; | ||
* import { PluginPostPublishPanel } from '@wordpress/edit-post'; | ||
* | ||
* const MyPluginPostPublishPanel = () => ( | ||
* <PluginPostPublishPanel | ||
* className="my-plugin-post-publish-panel" | ||
* title={ __( 'My panel title' ) } | ||
* initialOpen={ true } | ||
* > | ||
* { __( 'My panel content' ) } | ||
* </PluginPostPublishPanel> | ||
* ); | ||
* ``` | ||
* | ||
* @return {Component} The component to be rendered. | ||
*/ | ||
const PluginPostPublishPanel = ( { | ||
children, | ||
className, | ||
title, | ||
initialOpen = false, | ||
icon, | ||
} ) => { | ||
const { icon: pluginIcon } = usePluginContext(); | ||
|
||
return ( | ||
<Fill> | ||
<PanelBody | ||
className={ className } | ||
initialOpen={ initialOpen || ! title } | ||
title={ title } | ||
icon={ icon ?? pluginIcon } | ||
> | ||
{ children } | ||
</PanelBody> | ||
</Fill> | ||
); | ||
}; | ||
|
||
PluginPostPublishPanel.Slot = Slot; | ||
|
||
export default PluginPostPublishPanel; | ||
import deprecated from '@wordpress/deprecated'; | ||
import { PluginPostPublishPanel } from '@wordpress/editor'; | ||
|
||
// TODO: need to add to `editor` README.md manually.. | ||
export default function EditPostPluginPostPublishPanel( props ) { | ||
deprecated( 'wp.editPost.PluginPostPublishPanel', { | ||
since: '6.6', | ||
version: '6.8', | ||
alternative: 'wp.editor.PluginPostPublishPanel', | ||
} ); | ||
return <PluginPostPublishPanel { ...props } />; | ||
} |
Oops, something went wrong.