diff --git a/packages/edit-post/README.md b/packages/edit-post/README.md index de3c7d904ac607..4b0585337ebd3b 100644 --- a/packages/edit-post/README.md +++ b/packages/edit-post/README.md @@ -106,43 +106,9 @@ _Returns_ ### PluginPostPublishPanel -Renders provided content to the post-publish panel in the publish flow (side panel that opens after a user publishes the post). - -_Usage_ - -```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' ) - ); -} -``` +> **Deprecated** since 6.6, use `wp.editor.PluginPostPublishPanel` instead. -```jsx -// Using ESNext syntax -import { __ } from '@wordpress/i18n'; -import { PluginPostPublishPanel } from '@wordpress/edit-post'; - -const MyPluginPostPublishPanel = () => ( - - { __( 'My panel content' ) } - -); -``` +Renders provided content to the post-publish panel in the publish flow (side panel that opens after a user publishes the post). _Parameters_ @@ -203,43 +169,9 @@ _Returns_ ### PluginPrePublishPanel -Renders provided content to the pre-publish side panel in the publish flow (side panel that opens when a user first pushes "Publish" from the main editor). - -_Usage_ - -```js -// Using ES5 syntax -var __ = wp.i18n.__; -var PluginPrePublishPanel = wp.editPost.PluginPrePublishPanel; - -function MyPluginPrePublishPanel() { - return React.createElement( - PluginPrePublishPanel, - { - className: 'my-plugin-pre-publish-panel', - title: __( 'My panel title' ), - initialOpen: true, - }, - __( 'My panel content' ) - ); -} -``` +> **Deprecated** since 6.6, use `wp.editor.PluginPrePublishPanel` instead. -```jsx -// Using ESNext syntax -import { __ } from '@wordpress/i18n'; -import { PluginPrePublishPanel } from '@wordpress/edit-post'; - -const MyPluginPrePublishPanel = () => ( - - { __( 'My panel content' ) } - -); -``` +Renders provided content to the pre-publish side panel in the publish flow (side panel that opens when a user first pushes "Publish" from the main editor). _Parameters_ diff --git a/packages/edit-post/src/components/layout/actions-panel.js b/packages/edit-post/src/components/layout/actions-panel.js index df9f3cc28c57e9..6914cf6ff3c068 100644 --- a/packages/edit-post/src/components/layout/actions-panel.js +++ b/packages/edit-post/src/components/layout/actions-panel.js @@ -4,6 +4,8 @@ import { EntitiesSavedStates, PostPublishPanel, + PluginPrePublishPanel, + PluginPostPublishPanel, store as editorStore, } from '@wordpress/editor'; import { useSelect, useDispatch } from '@wordpress/data'; @@ -14,8 +16,6 @@ import { useCallback } from '@wordpress/element'; /** * Internal dependencies */ -import PluginPostPublishPanel from '../sidebar/plugin-post-publish-panel'; -import PluginPrePublishPanel from '../sidebar/plugin-pre-publish-panel'; import { store as editPostStore } from '../../store'; const { Fill, Slot } = createSlotFill( 'ActionsPanel' ); diff --git a/packages/edit-post/src/components/sidebar/plugin-post-publish-panel/index.js b/packages/edit-post/src/components/sidebar/plugin-post-publish-panel/index.js index 71de03b35b56ab..4d4838214b2829 100644 --- a/packages/edit-post/src/components/sidebar/plugin-post-publish-panel/index.js +++ b/packages/edit-post/src/components/sidebar/plugin-post-publish-panel/index.js @@ -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 = () => ( - * - * { __( 'My panel content' ) } - * - * ); - * ``` - * * @return {Component} The component to be rendered. */ -const PluginPostPublishPanel = ( { - children, - className, - title, - initialOpen = false, - icon, -} ) => { - const { icon: pluginIcon } = usePluginContext(); - - return ( - - - { children } - - - ); -}; - -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 ; +} diff --git a/packages/edit-post/src/components/sidebar/plugin-pre-publish-panel/index.js b/packages/edit-post/src/components/sidebar/plugin-pre-publish-panel/index.js index 014a7b31176a29..4353c1f6fd2ae9 100644 --- a/packages/edit-post/src/components/sidebar/plugin-pre-publish-panel/index.js +++ b/packages/edit-post/src/components/sidebar/plugin-pre-publish-panel/index.js @@ -1,15 +1,15 @@ /** * WordPress dependencies */ -import { createSlotFill, PanelBody } from '@wordpress/components'; -import { usePluginContext } from '@wordpress/plugins'; - -const { Fill, Slot } = createSlotFill( 'PluginPrePublishPanel' ); +import deprecated from '@wordpress/deprecated'; +import { PluginPrePublishPanel } from '@wordpress/editor'; /** * Renders provided content to the pre-publish side panel in the publish flow * (side panel that opens when a user first pushes "Publish" from the main editor). * + * @deprecated since 6.6, use `wp.editor.PluginPrePublishPanel` instead. + * * @param {Object} props Component props. * @param {string} [props.className] An optional class name added to the panel. * @param {string} [props.title] Title displayed at the top of the panel. @@ -20,67 +20,13 @@ const { Fill, Slot } = createSlotFill( 'PluginPrePublishPanel' ); * the sidebar is pinned to toolbar. * @param {Element} props.children Children to be rendered * - * @example - * ```js - * // Using ES5 syntax - * var __ = wp.i18n.__; - * var PluginPrePublishPanel = wp.editPost.PluginPrePublishPanel; - * - * function MyPluginPrePublishPanel() { - * return React.createElement( - * PluginPrePublishPanel, - * { - * className: 'my-plugin-pre-publish-panel', - * title: __( 'My panel title' ), - * initialOpen: true, - * }, - * __( 'My panel content' ) - * ); - * } - * ``` - * - * @example - * ```jsx - * // Using ESNext syntax - * import { __ } from '@wordpress/i18n'; - * import { PluginPrePublishPanel } from '@wordpress/edit-post'; - * - * const MyPluginPrePublishPanel = () => ( - * - * { __( 'My panel content' ) } - * - * ); - * ``` - * * @return {Component} The component to be rendered. */ -const PluginPrePublishPanel = ( { - children, - className, - title, - initialOpen = false, - icon, -} ) => { - const { icon: pluginIcon } = usePluginContext(); - - return ( - - - { children } - - - ); -}; - -PluginPrePublishPanel.Slot = Slot; - -export default PluginPrePublishPanel; +export default function EditPostPluginPrePublishPanel( props ) { + deprecated( 'wp.editPost.PluginPrePublishPanel', { + since: '6.6', + version: '6.8', + alternative: 'wp.editor.PluginPrePublishPanel', + } ); + return ; +} diff --git a/packages/editor/src/components/index.js b/packages/editor/src/components/index.js index 773a8936af092c..030db31a4023b9 100644 --- a/packages/editor/src/components/index.js +++ b/packages/editor/src/components/index.js @@ -28,6 +28,8 @@ export { default as PageAttributesParent } from './page-attributes/parent'; export { default as PageTemplate } from './post-template/classic-theme'; export { default as PluginDocumentSettingPanel } from './plugin-document-setting-panel'; export { default as PluginBlockSettingsMenuItem } from './block-settings-menu/plugin-block-settings-menu-item'; +export { default as PluginPostPublishPanel } from './plugin-post-publish-panel'; +export { default as PluginPrePublishPanel } from './plugin-pre-publish-panel'; export { default as PostTemplatePanel } from './post-template/panel'; export { default as PostAuthor } from './post-author'; export { default as PostAuthorCheck } from './post-author/check'; diff --git a/packages/editor/src/components/plugin-post-publish-panel/index.js b/packages/editor/src/components/plugin-post-publish-panel/index.js new file mode 100644 index 00000000000000..d9edf93e2d4be3 --- /dev/null +++ b/packages/editor/src/components/plugin-post-publish-panel/index.js @@ -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 = () => ( + * + * { __( 'My panel content' ) } + * + * ); + * ``` + * + * @return {Component} The component to be rendered. + */ +const PluginPostPublishPanel = ( { + children, + className, + title, + initialOpen = false, + icon, +} ) => { + const { icon: pluginIcon } = usePluginContext(); + + return ( + + + { children } + + + ); +}; + +PluginPostPublishPanel.Slot = Slot; + +export default PluginPostPublishPanel; diff --git a/packages/edit-post/src/components/sidebar/plugin-post-publish-panel/test/__snapshots__/index.js.snap b/packages/editor/src/components/plugin-post-publish-panel/test/__snapshots__/index.js.snap similarity index 100% rename from packages/edit-post/src/components/sidebar/plugin-post-publish-panel/test/__snapshots__/index.js.snap rename to packages/editor/src/components/plugin-post-publish-panel/test/__snapshots__/index.js.snap diff --git a/packages/edit-post/src/components/sidebar/plugin-post-publish-panel/test/index.js b/packages/editor/src/components/plugin-post-publish-panel/test/index.js similarity index 100% rename from packages/edit-post/src/components/sidebar/plugin-post-publish-panel/test/index.js rename to packages/editor/src/components/plugin-post-publish-panel/test/index.js diff --git a/packages/editor/src/components/plugin-pre-publish-panel/index.js b/packages/editor/src/components/plugin-pre-publish-panel/index.js new file mode 100644 index 00000000000000..1bd7b4754baae3 --- /dev/null +++ b/packages/editor/src/components/plugin-pre-publish-panel/index.js @@ -0,0 +1,67 @@ +/** + * WordPress dependencies + */ +import { createSlotFill, PanelBody } from '@wordpress/components'; +import { usePluginContext } from '@wordpress/plugins'; + +const { Fill, Slot } = createSlotFill( 'PluginPrePublishPanel' ); + +/** + * Renders provided content to the pre-publish side panel in the publish flow + * (side panel that opens when a user first pushes "Publish" from the main editor). + * + * @param {Object} props Component props. + * @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 { PluginPrePublishPanel } from '@wordpress/edit-post'; + * + * const MyPluginPrePublishPanel = () => ( + * + * { __( 'My panel content' ) } + * + * ); + * ``` + * + * @return {Component} The component to be rendered. + */ +const PluginPrePublishPanel = ( { + children, + className, + title, + initialOpen = false, + icon, +} ) => { + const { icon: pluginIcon } = usePluginContext(); + + return ( + + + { children } + + + ); +}; + +PluginPrePublishPanel.Slot = Slot; + +export default PluginPrePublishPanel; diff --git a/packages/edit-post/src/components/sidebar/plugin-pre-publish-panel/test/index.js b/packages/editor/src/components/plugin-pre-publish-panel/test/index.js similarity index 100% rename from packages/edit-post/src/components/sidebar/plugin-pre-publish-panel/test/index.js rename to packages/editor/src/components/plugin-pre-publish-panel/test/index.js