-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Editor: Move PluginPostPublishPanel and PluginPrePublishPanel to edit…
…or package
- Loading branch information
1 parent
24e550f
commit 77248eb
Showing
7 changed files
with
163 additions
and
207 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
79 changes: 12 additions & 67 deletions
79
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,28 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { usePluginContext } from '@wordpress/plugins'; | ||
import { createSlotFill, PanelBody } from '@wordpress/components'; | ||
|
||
const { Fill, Slot } = createSlotFill( 'PluginPostPublishPanel' ); | ||
import deprecated from '@wordpress/deprecated'; | ||
import { PluginPostPublishPanel } from '@wordpress/editor'; | ||
|
||
/** | ||
* Renders provided content to the post-publish panel in the publish flow | ||
* (side panel that opens after a user publishes the post). | ||
* | ||
* @deprecated since 6.6, use `wp.editor.PluginPostPublishPanel` instead. | ||
* | ||
* @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; | ||
export default function EditPostPluginPostPublishPanel( props ) { | ||
deprecated( 'wp.editPost.PluginPostPublishPanel', { | ||
since: '6.6', | ||
version: '6.8', | ||
alternative: 'wp.editor.PluginPostPublishPanel', | ||
} ); | ||
return <PluginPostPublishPanel { ...props } />; | ||
} |
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
64 changes: 64 additions & 0 deletions
64
packages/editor/src/components/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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* 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 | ||
* ```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; |
Oops, something went wrong.