Skip to content

Commit

Permalink
Editor: Consistently deprecate edit-post and edit-site slots (#61134)
Browse files Browse the repository at this point in the history
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: fabiankaegy <[email protected]>
  • Loading branch information
3 people authored Apr 26, 2024
1 parent ff01bcb commit bd8c9a7
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 119 deletions.
58 changes: 22 additions & 36 deletions packages/edit-post/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,65 +41,51 @@ _Parameters_

### PluginBlockSettingsMenuItem

Undocumented declaration.

### PluginDocumentSettingPanel
_Related_

Undocumented declaration.
- PluginBlockSettingsMenuItem in @wordpress/editor package.

### PluginMoreMenuItem
### PluginDocumentSettingPanel

Undocumented declaration.
_Related_

### PluginPostPublishPanel
- PluginDocumentSettingPanel in @wordpress/editor package.

> **Deprecated** since 6.6, use `wp.editor.PluginPostPublishPanel` instead.
### PluginMoreMenuItem

Renders provided content to the post-publish panel in the publish flow (side panel that opens after a user publishes the post).
_Related_

_Parameters_
- PluginMoreMenuItem in @wordpress/editor package.

- _props_ `Object`: Component properties.
- _props.className_ `[string]`: An optional class name added to the panel.
- _props.title_ `[string]`: Title displayed at the top of the panel.
- _props.initialOpen_ `[boolean]`: Whether to have the panel initially opened. When no title is provided it is always opened.
- _props.icon_ `[WPBlockTypeIconRender]`: 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.
- _props.children_ `Element`: Children to be rendered
### PluginPostPublishPanel

_Returns_
_Related_

- `Component`: The component to be rendered.
- PluginPostPublishPanel in @wordpress/editor package.

### PluginPostStatusInfo

Undocumented declaration.

### PluginPrePublishPanel

> **Deprecated** since 6.6, use `wp.editor.PluginPrePublishPanel` instead.
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).
_Related_

_Parameters_
- PluginPostStatusInfo in @wordpress/editor package.

- _props_ `Object`: Component props.
- _props.className_ `[string]`: An optional class name added to the panel.
- _props.title_ `[string]`: Title displayed at the top of the panel.
- _props.initialOpen_ `[boolean]`: Whether to have the panel initially opened. When no title is provided it is always opened.
- _props.icon_ `[WPBlockTypeIconRender]`: 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.
- _props.children_ `Element`: Children to be rendered
### PluginPrePublishPanel

_Returns_
_Related_

- `Component`: The component to be rendered.
- PluginPrePublishPanel in @wordpress/editor package.

### PluginSidebar

Undocumented declaration.
_Related_

- PluginSidebar in @wordpress/editor package.

### PluginSidebarMoreMenuItem

Undocumented declaration.
_Related_

- PluginSidebarMoreMenuItem in @wordpress/editor package.

### reinitializeEditor

Expand Down

This file was deleted.

This file was deleted.

87 changes: 87 additions & 0 deletions packages/edit-post/src/deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/**
* WordPress dependencies
*/
import {
PluginBlockSettingsMenuItem as EditorPluginBlockSettingsMenuItem,
PluginDocumentSettingPanel as EditorPluginDocumentSettingPanel,
PluginMoreMenuItem as EditorPluginMoreMenuItem,
PluginPrePublishPanel as EditorPluginPrePublishPanel,
PluginPostPublishPanel as EditorPluginPostPublishPanel,
PluginPostStatusInfo as EditorPluginPostStatusInfo,
PluginSidebar as EditorPluginSidebar,
PluginSidebarMoreMenuItem as EditorPluginSidebarMoreMenuItem,
} from '@wordpress/editor';
import deprecated from '@wordpress/deprecated';

const deprecateSlot = ( name ) => {
deprecated( `wp.editPost.${ name }`, {
since: '6.6',
alternative: `wp.editor.${ name }`,
} );
};

/* eslint-disable jsdoc/require-param */
/**
* @see PluginBlockSettingsMenuItem in @wordpress/editor package.
*/
export function PluginBlockSettingsMenuItem( props ) {
deprecateSlot( 'PluginBlockSettingsMenuItem' );
return <EditorPluginBlockSettingsMenuItem { ...props } />;
}

/**
* @see PluginDocumentSettingPanel in @wordpress/editor package.
*/
export function PluginDocumentSettingPanel( props ) {
deprecateSlot( 'PluginDocumentSettingPanel' );
return <EditorPluginDocumentSettingPanel { ...props } />;
}

/**
* @see PluginMoreMenuItem in @wordpress/editor package.
*/
export function PluginMoreMenuItem( props ) {
deprecateSlot( 'PluginMoreMenuItem' );
return <EditorPluginMoreMenuItem { ...props } />;
}

/**
* @see PluginPrePublishPanel in @wordpress/editor package.
*/
export function PluginPrePublishPanel( props ) {
deprecateSlot( 'PluginPrePublishPanel' );
return <EditorPluginPrePublishPanel { ...props } />;
}

/**
* @see PluginPostPublishPanel in @wordpress/editor package.
*/
export function PluginPostPublishPanel( props ) {
deprecateSlot( 'PluginPostPublishPanel' );
return <EditorPluginPostPublishPanel { ...props } />;
}

/**
* @see PluginPostStatusInfo in @wordpress/editor package.
*/
export function PluginPostStatusInfo( props ) {
deprecateSlot( 'PluginPostStatusInfo' );
return <EditorPluginPostStatusInfo { ...props } />;
}

/**
* @see PluginSidebar in @wordpress/editor package.
*/
export function PluginSidebar( props ) {
deprecateSlot( 'PluginSidebar' );
return <EditorPluginSidebar { ...props } />;
}

/**
* @see PluginSidebarMoreMenuItem in @wordpress/editor package.
*/
export function PluginSidebarMoreMenuItem( props ) {
deprecateSlot( 'PluginSidebarMoreMenuItem' );
return <EditorPluginSidebarMoreMenuItem { ...props } />;
}
/* eslint-enable jsdoc/require-param */
15 changes: 1 addition & 14 deletions packages/edit-post/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ import {
registerWidgetGroupBlock,
} from '@wordpress/widgets';
import {
PluginBlockSettingsMenuItem,
PluginDocumentSettingPanel,
PluginMoreMenuItem,
PluginPostStatusInfo,
PluginSidebar,
PluginSidebarMoreMenuItem,
privateApis as editorPrivateApis,
store as editorStore,
} from '@wordpress/editor';
Expand Down Expand Up @@ -165,15 +159,8 @@ export function reinitializeEditor() {
} );
}

export { PluginBlockSettingsMenuItem };
export { PluginDocumentSettingPanel };
export { PluginMoreMenuItem };
export { PluginPostStatusInfo };
export { PluginSidebar };
export { PluginSidebarMoreMenuItem };
export { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';
export { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';
export { default as __experimentalFullscreenModeClose } from './components/header/fullscreen-mode-close';
export { default as __experimentalMainDashboardButton } from './components/header/main-dashboard-button';
export { __experimentalPluginPostExcerpt };
export { store } from './store';
export * from './deprecated';
42 changes: 42 additions & 0 deletions packages/edit-site/src/deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* WordPress dependencies
*/
import {
PluginMoreMenuItem as EditorPluginMoreMenuItem,
PluginSidebar as EditorPluginSidebar,
PluginSidebarMoreMenuItem as EditorPluginSidebarMoreMenuItem,
} from '@wordpress/editor';
import deprecated from '@wordpress/deprecated';

const deprecateSlot = ( name ) => {
deprecated( `wp.editPost.${ name }`, {
since: '6.6',
alternative: `wp.editor.${ name }`,
} );
};

/* eslint-disable jsdoc/require-param */
/**
* @see PluginMoreMenuItem in @wordpress/editor package.
*/
export function PluginMoreMenuItem( props ) {
deprecateSlot( 'PluginMoreMenuItem' );
return <EditorPluginMoreMenuItem { ...props } />;
}

/**
* @see PluginSidebar in @wordpress/editor package.
*/
export function PluginSidebar( props ) {
deprecateSlot( 'PluginSidebar' );
return <EditorPluginSidebar { ...props } />;
}

/**
* @see PluginSidebarMoreMenuItem in @wordpress/editor package.
*/
export function PluginSidebarMoreMenuItem( props ) {
deprecateSlot( 'PluginSidebarMoreMenuItem' );
return <EditorPluginSidebarMoreMenuItem { ...props } />;
}
/* eslint-enable jsdoc/require-param */
11 changes: 2 additions & 9 deletions packages/edit-site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ import {
import { dispatch } from '@wordpress/data';
import deprecated from '@wordpress/deprecated';
import { createRoot } from '@wordpress/element';
import {
PluginMoreMenuItem,
PluginSidebar,
PluginSidebarMoreMenuItem,
store as editorStore,
} from '@wordpress/editor';
import { store as editorStore } from '@wordpress/editor';
import { store as preferencesStore } from '@wordpress/preferences';
import {
registerLegacyWidgetBlock,
Expand Down Expand Up @@ -102,8 +97,6 @@ export function reinitializeEditor() {
} );
}

export { PluginMoreMenuItem };
export { PluginSidebar };
export { PluginSidebarMoreMenuItem };
export { default as PluginTemplateSettingPanel } from './components/plugin-template-setting-panel';
export { store } from './store';
export * from './deprecated';

0 comments on commit bd8c9a7

Please sign in to comment.