Skip to content

Commit e5b0917

Browse files
youknowriadgziolo
authored andcommitted
Extensibiltiy: Support PluginBlockSettingsMenuItem in the site editor (WordPress#60033)
Co-authored-by: youknowriad <[email protected]> Co-authored-by: gziolo <[email protected]>
1 parent 299fd3b commit e5b0917

File tree

4 files changed

+6
-58
lines changed

4 files changed

+6
-58
lines changed

packages/edit-post/README.md

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -41,61 +41,7 @@ _Parameters_
4141

4242
### PluginBlockSettingsMenuItem
4343

44-
Renders a new item in the block settings menu.
45-
46-
_Usage_
47-
48-
```js
49-
// Using ES5 syntax
50-
var __ = wp.i18n.__;
51-
var PluginBlockSettingsMenuItem = wp.editPost.PluginBlockSettingsMenuItem;
52-
53-
function doOnClick() {
54-
// To be called when the user clicks the menu item.
55-
}
56-
57-
function MyPluginBlockSettingsMenuItem() {
58-
return React.createElement( PluginBlockSettingsMenuItem, {
59-
allowedBlocks: [ 'core/paragraph' ],
60-
icon: 'dashicon-name',
61-
label: __( 'Menu item text' ),
62-
onClick: doOnClick,
63-
} );
64-
}
65-
```
66-
67-
```jsx
68-
// Using ESNext syntax
69-
import { __ } from '@wordpress/i18n';
70-
import { PluginBlockSettingsMenuItem } from '@wordpress/edit-post';
71-
72-
const doOnClick = () => {
73-
// To be called when the user clicks the menu item.
74-
};
75-
76-
const MyPluginBlockSettingsMenuItem = () => (
77-
<PluginBlockSettingsMenuItem
78-
allowedBlocks={ [ 'core/paragraph' ] }
79-
icon="dashicon-name"
80-
label={ __( 'Menu item text' ) }
81-
onClick={ doOnClick }
82-
/>
83-
);
84-
```
85-
86-
_Parameters_
87-
88-
- _props_ `Object`: Component props.
89-
- _props.allowedBlocks_ `[Array]`: An array containing a list of block names for which the item should be shown. If not present, it'll be rendered for any block. If multiple blocks are selected, it'll be shown if and only if all of them are in the allowed list.
90-
- _props.icon_ `[WPBlockTypeIconRender]`: The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element.
91-
- _props.label_ `string`: The menu item text.
92-
- _props.onClick_ `Function`: Callback function to be executed when the user click the menu item.
93-
- _props.small_ `[boolean]`: Whether to render the label or not.
94-
- _props.role_ `[string]`: The ARIA role for the menu item.
95-
96-
_Returns_
97-
98-
- `Component`: The component to be rendered.
44+
Undocumented declaration.
9945

10046
### PluginDocumentSettingPanel
10147

packages/edit-post/src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
registerWidgetGroupBlock,
1616
} from '@wordpress/widgets';
1717
import {
18+
PluginBlockSettingsMenuItem,
1819
PluginDocumentSettingPanel,
1920
privateApis as editorPrivateApis,
2021
store as editorStore,
@@ -161,7 +162,7 @@ export function reinitializeEditor() {
161162
} );
162163
}
163164

164-
export { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';
165+
export { PluginBlockSettingsMenuItem };
165166
export { PluginDocumentSettingPanel };
166167
export { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';
167168
export { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';

packages/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-item.js renamed to packages/editor/src/components/block-settings-menu/plugin-block-settings-menu-item.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const shouldRenderItem = ( selectedBlocks, allowedBlocks ) =>
3838
* ```js
3939
* // Using ES5 syntax
4040
* var __ = wp.i18n.__;
41-
* var PluginBlockSettingsMenuItem = wp.editPost.PluginBlockSettingsMenuItem;
41+
* var PluginBlockSettingsMenuItem = wp.editor.PluginBlockSettingsMenuItem;
4242
*
4343
* function doOnClick(){
4444
* // To be called when the user clicks the menu item.
@@ -61,7 +61,7 @@ const shouldRenderItem = ( selectedBlocks, allowedBlocks ) =>
6161
* ```jsx
6262
* // Using ESNext syntax
6363
* import { __ } from '@wordpress/i18n';
64-
* import { PluginBlockSettingsMenuItem } from '@wordpress/edit-post';
64+
* import { PluginBlockSettingsMenuItem } from '@wordpress/editor';
6565
*
6666
* const doOnClick = ( ) => {
6767
* // To be called when the user clicks the menu item.

packages/editor/src/components/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export { default as PageAttributesPanel } from './page-attributes/panel';
2727
export { default as PageAttributesParent } from './page-attributes/parent';
2828
export { default as PageTemplate } from './post-template/classic-theme';
2929
export { default as PluginDocumentSettingPanel } from './plugin-document-setting-panel';
30+
export { default as PluginBlockSettingsMenuItem } from './block-settings-menu/plugin-block-settings-menu-item';
3031
export { default as PostTemplatePanel } from './post-template/panel';
3132
export { default as PostAuthor } from './post-author';
3233
export { default as PostAuthorCheck } from './post-author/check';

0 commit comments

Comments
 (0)