@wordpress/block-library 7.11.0 → 7.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/archives/edit.js +7 -0
- package/build/archives/edit.js.map +1 -1
- package/build/archives/index.js +4 -0
- package/build/archives/index.js.map +1 -1
- package/build/block/edit.js +4 -2
- package/build/block/edit.js.map +1 -1
- package/build/block/edit.native.js +4 -2
- package/build/block/edit.native.js.map +1 -1
- package/build/calendar/edit.js +12 -5
- package/build/calendar/edit.js.map +1 -1
- package/build/columns/edit.native.js +2 -1
- package/build/columns/edit.native.js.map +1 -1
- package/build/cover/edit/resizable-cover.js +6 -0
- package/build/cover/edit/resizable-cover.js.map +1 -1
- package/build/group/transforms.js +5 -0
- package/build/group/transforms.js.map +1 -1
- package/build/index.native.js +17 -4
- package/build/index.native.js.map +1 -1
- package/build/list/index.js +6 -0
- package/build/list/index.js.map +1 -1
- package/build/list/v2/edit.js +16 -5
- package/build/list/v2/edit.js.map +1 -1
- package/build/list/v2/tag-name.js +31 -0
- package/build/list/v2/tag-name.js.map +1 -0
- package/build/list/v2/tag-name.native.js +32 -0
- package/build/list/v2/tag-name.native.js.map +1 -0
- package/build/list/v2/transforms.js +1 -11
- package/build/list/v2/transforms.js.map +1 -1
- package/build/list-item/edit.js +1 -0
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/edit.native.js +158 -0
- package/build/list-item/edit.native.js.map +1 -0
- package/build/list-item/icons.native.js +53 -0
- package/build/list-item/icons.native.js.map +1 -0
- package/build/list-item/list-style-type.native.js +136 -0
- package/build/list-item/list-style-type.native.js.map +1 -0
- package/build/media-text/deprecated.js +188 -66
- package/build/media-text/deprecated.js.map +1 -1
- package/build/media-text/edit.js +2 -1
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/media-container.js +1 -1
- package/build/media-text/media-container.js.map +1 -1
- package/build/navigation/edit/index.js +68 -123
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +11 -14
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +4 -2
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +13 -3
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js +5 -1
- package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build/navigation/edit/use-inner-blocks.js +43 -0
- package/build/navigation/edit/use-inner-blocks.js.map +1 -0
- package/build/navigation/edit/utils.js +28 -0
- package/build/navigation/edit/utils.js.map +1 -0
- package/build/navigation/use-navigation-menu.js +7 -3
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/post-author/edit.js +5 -2
- package/build/post-author/edit.js.map +1 -1
- package/build/post-author-biography/edit.js +7 -1
- package/build/post-author-biography/edit.js.map +1 -1
- package/build/post-content/edit.js +4 -2
- package/build/post-content/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +16 -2
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-featured-image/index.js +9 -0
- package/build/post-featured-image/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +42 -9
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +21 -14
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query-title/edit.js +20 -7
- package/build/query-title/edit.js.map +1 -1
- package/build/query-title/index.js +4 -0
- package/build/query-title/index.js.map +1 -1
- package/build/query-title/variations.js +10 -0
- package/build/query-title/variations.js.map +1 -1
- package/build/quote/transforms.js +2 -2
- package/build/quote/transforms.js.map +1 -1
- package/build/separator/edit.js +1 -1
- package/build/separator/edit.js.map +1 -1
- package/build/social-links/edit.js +1 -0
- package/build/social-links/edit.js.map +1 -1
- package/build/template-part/edit/index.js +4 -2
- package/build/template-part/edit/index.js.map +1 -1
- package/build-module/archives/edit.js +7 -0
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/archives/index.js +4 -0
- package/build-module/archives/index.js.map +1 -1
- package/build-module/block/edit.js +5 -3
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/edit.native.js +5 -3
- package/build-module/block/edit.native.js.map +1 -1
- package/build-module/calendar/edit.js +12 -4
- package/build-module/calendar/edit.js.map +1 -1
- package/build-module/columns/edit.native.js +3 -2
- package/build-module/columns/edit.native.js.map +1 -1
- package/build-module/cover/edit/resizable-cover.js +6 -0
- package/build-module/cover/edit/resizable-cover.js.map +1 -1
- package/build-module/group/transforms.js +5 -0
- package/build-module/group/transforms.js.map +1 -1
- package/build-module/index.native.js +16 -4
- package/build-module/index.native.js.map +1 -1
- package/build-module/list/index.js +1 -1
- package/build-module/list/index.js.map +1 -1
- package/build-module/list/v2/edit.js +15 -5
- package/build-module/list/v2/edit.js.map +1 -1
- package/build-module/list/v2/tag-name.js +21 -0
- package/build-module/list/v2/tag-name.js.map +1 -0
- package/build-module/list/v2/tag-name.native.js +21 -0
- package/build-module/list/v2/tag-name.native.js.map +1 -0
- package/build-module/list/v2/transforms.js +1 -10
- package/build-module/list/v2/transforms.js.map +1 -1
- package/build-module/list-item/edit.js +1 -3
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/edit.native.js +141 -0
- package/build-module/list-item/edit.native.js.map +1 -0
- package/build-module/list-item/icons.native.js +37 -0
- package/build-module/list-item/icons.native.js.map +1 -0
- package/build-module/list-item/list-style-type.native.js +124 -0
- package/build-module/list-item/list-style-type.native.js.map +1 -0
- package/build-module/media-text/deprecated.js +189 -65
- package/build-module/media-text/deprecated.js.map +1 -1
- package/build-module/media-text/edit.js +2 -1
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/media-container.js +1 -1
- package/build-module/media-text/media-container.js.map +1 -1
- package/build-module/navigation/edit/index.js +66 -122
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +12 -15
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +4 -2
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +12 -3
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js +5 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build-module/navigation/edit/use-inner-blocks.js +33 -0
- package/build-module/navigation/edit/use-inner-blocks.js.map +1 -0
- package/build-module/navigation/edit/utils.js +21 -0
- package/build-module/navigation/edit/utils.js.map +1 -0
- package/build-module/navigation/use-navigation-menu.js +7 -3
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/post-author/edit.js +5 -2
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-author-biography/edit.js +6 -1
- package/build-module/post-author-biography/edit.js.map +1 -1
- package/build-module/post-content/edit.js +5 -3
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +17 -3
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-featured-image/index.js +9 -0
- package/build-module/post-featured-image/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +42 -9
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +16 -12
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query-title/edit.js +20 -8
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/query-title/index.js +4 -0
- package/build-module/query-title/index.js.map +1 -1
- package/build-module/query-title/variations.js +10 -0
- package/build-module/query-title/variations.js.map +1 -1
- package/build-module/quote/transforms.js +3 -3
- package/build-module/quote/transforms.js.map +1 -1
- package/build-module/separator/edit.js +1 -1
- package/build-module/separator/edit.js.map +1 -1
- package/build-module/social-links/edit.js +1 -0
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/template-part/edit/index.js +5 -3
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-style/editor-rtl.css +10 -0
- package/build-style/editor.css +10 -0
- package/build-style/latest-posts/editor-rtl.css +3 -0
- package/build-style/latest-posts/editor.css +3 -0
- package/build-style/navigation/style-rtl.css +17 -19
- package/build-style/navigation/style.css +17 -19
- package/build-style/query/editor-rtl.css +7 -0
- package/build-style/query/editor.css +7 -0
- package/build-style/query-pagination/style-rtl.css +6 -0
- package/build-style/query-pagination/style.css +6 -0
- package/build-style/search/style-rtl.css +2 -0
- package/build-style/search/style.css +2 -0
- package/build-style/style-rtl.css +26 -19
- package/build-style/style.css +26 -19
- package/build-style/tag-cloud/style-rtl.css +1 -0
- package/build-style/tag-cloud/style.css +1 -0
- package/package.json +28 -29
- package/src/archives/block.json +4 -0
- package/src/archives/edit.js +12 -1
- package/src/archives/index.php +5 -3
- package/src/audio/test/__snapshots__/edit.native.js.snap +16 -2
- package/src/block/edit.js +4 -4
- package/src/block/edit.native.js +4 -4
- package/src/calendar/edit.js +11 -4
- package/src/columns/edit.native.js +4 -2
- package/src/cover/edit/resizable-cover.js +6 -0
- package/src/cover/index.php +2 -2
- package/src/file/test/__snapshots__/edit.native.js.snap +32 -4
- package/src/group/transforms.js +7 -0
- package/src/home-link/index.php +8 -17
- package/src/image/test/edit.native.js +6 -10
- package/src/index.native.js +15 -2
- package/src/latest-posts/editor.scss +5 -0
- package/src/list/index.js +1 -1
- package/src/list/test/__snapshots__/edit.native.js.snap +133 -0
- package/src/list/test/edit.native.js +511 -7
- package/src/list/v2/edit.js +12 -4
- package/src/list/v2/tag-name.js +13 -0
- package/src/list/v2/tag-name.native.js +12 -0
- package/src/list/v2/transforms.js +1 -9
- package/src/list-item/edit.js +1 -1
- package/src/list-item/edit.native.js +148 -0
- package/src/list-item/icons.native.js +34 -0
- package/src/list-item/list-style-type.native.js +139 -0
- package/src/list-item/style.native.scss +45 -0
- package/src/media-text/deprecated.js +561 -415
- package/src/media-text/edit.js +1 -0
- package/src/media-text/media-container.js +3 -1
- package/src/media-text/test/media-container.js +24 -0
- package/src/navigation/edit/index.js +83 -164
- package/src/navigation/edit/navigation-menu-selector.js +12 -26
- package/src/navigation/edit/placeholder/index.js +4 -2
- package/src/navigation/edit/responsive-wrapper.js +24 -3
- package/src/navigation/edit/use-create-navigation-menu.js +4 -0
- package/src/navigation/edit/use-inner-blocks.js +39 -0
- package/src/navigation/edit/utils.js +30 -0
- package/src/navigation/index.php +6 -0
- package/src/navigation/style.scss +12 -22
- package/src/navigation/use-navigation-menu.js +9 -5
- package/src/navigation-link/index.php +1 -1
- package/src/navigation-submenu/index.php +1 -1
- package/src/page-list/index.php +4 -4
- package/src/post-author/edit.js +6 -3
- package/src/post-author-biography/edit.js +4 -1
- package/src/post-content/edit.js +4 -4
- package/src/post-featured-image/block.json +9 -0
- package/src/post-featured-image/edit.js +23 -1
- package/src/post-featured-image/index.php +3 -1
- package/src/post-title/index.php +2 -1
- package/src/preformatted/test/__snapshots__/edit.native.js.snap +16 -2
- package/src/query/edit/inspector-controls/index.js +129 -65
- package/src/query/edit/inspector-controls/taxonomy-controls.js +17 -10
- package/src/query/editor.scss +9 -0
- package/src/query-pagination/style.scss +14 -0
- package/src/query-title/block.json +4 -0
- package/src/query-title/edit.js +33 -6
- package/src/query-title/index.php +17 -1
- package/src/query-title/variations.js +13 -0
- package/src/quote/transforms.js +3 -7
- package/src/search/style.scss +2 -0
- package/src/search/test/__snapshots__/edit.native.js.snap +56 -7
- package/src/separator/edit.js +1 -1
- package/src/separator/test/edit.js +5 -3
- package/src/site-title/index.php +8 -9
- package/src/social-link/index.php +1 -1
- package/src/social-links/edit.js +1 -0
- package/src/tag-cloud/style.scss +1 -0
- package/src/template-part/edit/index.js +4 -4
package/src/media-text/edit.js
CHANGED
|
@@ -293,6 +293,7 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
|
|
|
293
293
|
slug={ mediaSizeSlug }
|
|
294
294
|
imageSizeOptions={ imageSizeOptions }
|
|
295
295
|
isResizable={ false }
|
|
296
|
+
imageSizeHelp={ __( 'Select which image size to load.' ) }
|
|
296
297
|
/>
|
|
297
298
|
) }
|
|
298
299
|
{ mediaUrl && (
|
|
@@ -36,7 +36,9 @@ export function imageFillStyles( url, focalPoint ) {
|
|
|
36
36
|
? {
|
|
37
37
|
backgroundImage: `url(${ url })`,
|
|
38
38
|
backgroundPosition: focalPoint
|
|
39
|
-
? `${ focalPoint.x * 100 }% ${
|
|
39
|
+
? `${ Math.round( focalPoint.x * 100 ) }% ${ Math.round(
|
|
40
|
+
focalPoint.y * 100
|
|
41
|
+
) }%`
|
|
40
42
|
: `50% 50%`,
|
|
41
43
|
}
|
|
42
44
|
: {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { imageFillStyles } from '../media-container';
|
|
5
|
+
|
|
6
|
+
describe( 'imageFillStyles()', () => {
|
|
7
|
+
it( 'should return image url', () => {
|
|
8
|
+
const { backgroundImage } = imageFillStyles( 'image.jpg' );
|
|
9
|
+
expect( backgroundImage ).toBe( 'url(image.jpg)' );
|
|
10
|
+
} );
|
|
11
|
+
|
|
12
|
+
it( 'should return centered background position', () => {
|
|
13
|
+
const { backgroundPosition } = imageFillStyles( 'image.jpg' );
|
|
14
|
+
expect( backgroundPosition ).toBe( '50% 50%' );
|
|
15
|
+
} );
|
|
16
|
+
|
|
17
|
+
it( 'should return custom background position', () => {
|
|
18
|
+
const { backgroundPosition } = imageFillStyles( 'image.jpg', {
|
|
19
|
+
x: 0.56,
|
|
20
|
+
y: 0.57,
|
|
21
|
+
} );
|
|
22
|
+
expect( backgroundPosition ).toBe( '56% 57%' );
|
|
23
|
+
} );
|
|
24
|
+
} );
|
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
InspectorControls,
|
|
18
18
|
BlockControls,
|
|
19
19
|
useBlockProps,
|
|
20
|
-
|
|
20
|
+
__experimentalRecursionProvider as RecursionProvider,
|
|
21
|
+
__experimentalUseHasRecursion as useHasRecursion,
|
|
21
22
|
store as blockEditorStore,
|
|
22
23
|
withColors,
|
|
23
24
|
PanelColorSettings,
|
|
@@ -28,7 +29,7 @@ import {
|
|
|
28
29
|
} from '@wordpress/block-editor';
|
|
29
30
|
import { EntityProvider } from '@wordpress/core-data';
|
|
30
31
|
|
|
31
|
-
import { useDispatch,
|
|
32
|
+
import { useDispatch, useRegistry } from '@wordpress/data';
|
|
32
33
|
import {
|
|
33
34
|
PanelBody,
|
|
34
35
|
ToggleControl,
|
|
@@ -60,40 +61,9 @@ import useConvertClassicToBlockMenu, {
|
|
|
60
61
|
CLASSIC_MENU_CONVERSION_PENDING,
|
|
61
62
|
CLASSIC_MENU_CONVERSION_SUCCESS,
|
|
62
63
|
} from './use-convert-classic-menu-to-block-menu';
|
|
63
|
-
import useCreateNavigationMenu
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
CREATE_NAVIGATION_MENU_SUCCESS,
|
|
67
|
-
} from './use-create-navigation-menu';
|
|
68
|
-
|
|
69
|
-
const EMPTY_ARRAY = [];
|
|
70
|
-
|
|
71
|
-
function getComputedStyle( node ) {
|
|
72
|
-
return node.ownerDocument.defaultView.getComputedStyle( node );
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function detectColors( colorsDetectionElement, setColor, setBackground ) {
|
|
76
|
-
if ( ! colorsDetectionElement ) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
setColor( getComputedStyle( colorsDetectionElement ).color );
|
|
80
|
-
|
|
81
|
-
let backgroundColorNode = colorsDetectionElement;
|
|
82
|
-
let backgroundColor =
|
|
83
|
-
getComputedStyle( backgroundColorNode ).backgroundColor;
|
|
84
|
-
while (
|
|
85
|
-
backgroundColor === 'rgba(0, 0, 0, 0)' &&
|
|
86
|
-
backgroundColorNode.parentNode &&
|
|
87
|
-
backgroundColorNode.parentNode.nodeType ===
|
|
88
|
-
backgroundColorNode.parentNode.ELEMENT_NODE
|
|
89
|
-
) {
|
|
90
|
-
backgroundColorNode = backgroundColorNode.parentNode;
|
|
91
|
-
backgroundColor =
|
|
92
|
-
getComputedStyle( backgroundColorNode ).backgroundColor;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
setBackground( backgroundColor );
|
|
96
|
-
}
|
|
64
|
+
import useCreateNavigationMenu from './use-create-navigation-menu';
|
|
65
|
+
import { useInnerBlocks } from './use-inner-blocks';
|
|
66
|
+
import { detectColors } from './utils';
|
|
97
67
|
|
|
98
68
|
function Navigation( {
|
|
99
69
|
attributes,
|
|
@@ -135,51 +105,58 @@ function Navigation( {
|
|
|
135
105
|
setAttributes( { ref: postId } );
|
|
136
106
|
};
|
|
137
107
|
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
);
|
|
108
|
+
const recursionId = `navigationMenu/${ ref }`;
|
|
109
|
+
const hasAlreadyRendered = useHasRecursion( recursionId );
|
|
141
110
|
|
|
142
111
|
// Preload classic menus, so that they don't suddenly pop-in when viewing
|
|
143
112
|
// the Select Menu dropdown.
|
|
144
113
|
useNavigationEntities();
|
|
145
114
|
|
|
146
|
-
const [
|
|
147
|
-
|
|
148
|
-
|
|
115
|
+
const [ showNavigationMenuStatusNotice, hideNavigationMenuStatusNotice ] =
|
|
116
|
+
useNavigationNotice( {
|
|
117
|
+
name: 'block-library/core/navigation/status',
|
|
118
|
+
} );
|
|
149
119
|
|
|
150
|
-
const [
|
|
120
|
+
const [ showClassicMenuConversionNotice, hideClassicMenuConversionNotice ] =
|
|
151
121
|
useNavigationNotice( {
|
|
152
|
-
name: 'block-library/core/navigation/
|
|
122
|
+
name: 'block-library/core/navigation/classic-menu-conversion',
|
|
153
123
|
} );
|
|
154
124
|
|
|
125
|
+
const [
|
|
126
|
+
showNavigationMenuPermissionsNotice,
|
|
127
|
+
hideNavigationMenuPermissionsNotice,
|
|
128
|
+
] = useNavigationNotice( {
|
|
129
|
+
name: 'block-library/core/navigation/permissions/update',
|
|
130
|
+
} );
|
|
131
|
+
|
|
155
132
|
const {
|
|
156
133
|
create: createNavigationMenu,
|
|
157
134
|
status: createNavigationMenuStatus,
|
|
158
135
|
error: createNavigationMenuError,
|
|
159
136
|
value: createNavigationMenuPost,
|
|
137
|
+
isPending: isCreatingNavigationMenu,
|
|
138
|
+
isSuccess: createNavigationMenuIsSuccess,
|
|
139
|
+
isError: createNavigationMenuIsError,
|
|
160
140
|
} = useCreateNavigationMenu( clientId );
|
|
161
141
|
|
|
162
|
-
const isCreatingNavigationMenu =
|
|
163
|
-
createNavigationMenuStatus === CREATE_NAVIGATION_MENU_PENDING;
|
|
164
|
-
|
|
165
142
|
useEffect( () => {
|
|
166
|
-
|
|
143
|
+
hideNavigationMenuStatusNotice();
|
|
167
144
|
|
|
168
|
-
if (
|
|
145
|
+
if ( isCreatingNavigationMenu ) {
|
|
169
146
|
speak( __( `Creating Navigation Menu.` ) );
|
|
170
147
|
}
|
|
171
148
|
|
|
172
|
-
if (
|
|
149
|
+
if ( createNavigationMenuIsSuccess ) {
|
|
173
150
|
setRef( createNavigationMenuPost.id );
|
|
174
151
|
selectBlock( clientId );
|
|
175
152
|
|
|
176
|
-
|
|
153
|
+
showNavigationMenuStatusNotice(
|
|
177
154
|
__( `Navigation Menu successfully created.` )
|
|
178
155
|
);
|
|
179
156
|
}
|
|
180
157
|
|
|
181
|
-
if (
|
|
182
|
-
|
|
158
|
+
if ( createNavigationMenuIsError ) {
|
|
159
|
+
showNavigationMenuStatusNotice(
|
|
183
160
|
__( 'Failed to create Navigation Menu.' )
|
|
184
161
|
);
|
|
185
162
|
}
|
|
@@ -194,37 +171,13 @@ function Navigation( {
|
|
|
194
171
|
hasUncontrolledInnerBlocks,
|
|
195
172
|
uncontrolledInnerBlocks,
|
|
196
173
|
isInnerBlockSelected,
|
|
197
|
-
|
|
198
|
-
} =
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
// This relies on the fact that `getBlock` won't return controlled
|
|
204
|
-
// inner blocks, while `getBlocks` does. It might be more stable to
|
|
205
|
-
// introduce a selector like `getUncontrolledInnerBlocks`, just in
|
|
206
|
-
// case `getBlock` is fixed.
|
|
207
|
-
const _uncontrolledInnerBlocks = getBlock( clientId ).innerBlocks;
|
|
208
|
-
const _hasUncontrolledInnerBlocks =
|
|
209
|
-
!! _uncontrolledInnerBlocks?.length;
|
|
210
|
-
const _controlledInnerBlocks = _hasUncontrolledInnerBlocks
|
|
211
|
-
? EMPTY_ARRAY
|
|
212
|
-
: getBlocks( clientId );
|
|
213
|
-
const innerBlocks = _hasUncontrolledInnerBlocks
|
|
214
|
-
? _uncontrolledInnerBlocks
|
|
215
|
-
: _controlledInnerBlocks;
|
|
216
|
-
|
|
217
|
-
return {
|
|
218
|
-
hasSubmenus: !! innerBlocks.find(
|
|
219
|
-
( block ) => block.name === 'core/navigation-submenu'
|
|
220
|
-
),
|
|
221
|
-
hasUncontrolledInnerBlocks: _hasUncontrolledInnerBlocks,
|
|
222
|
-
uncontrolledInnerBlocks: _uncontrolledInnerBlocks,
|
|
223
|
-
isInnerBlockSelected: hasSelectedInnerBlock( clientId, true ),
|
|
224
|
-
};
|
|
225
|
-
},
|
|
226
|
-
[ clientId ]
|
|
174
|
+
innerBlocks,
|
|
175
|
+
} = useInnerBlocks( clientId );
|
|
176
|
+
|
|
177
|
+
const hasSubmenus = !! innerBlocks.find(
|
|
178
|
+
( block ) => block.name === 'core/navigation-submenu'
|
|
227
179
|
);
|
|
180
|
+
|
|
228
181
|
const {
|
|
229
182
|
replaceInnerBlocks,
|
|
230
183
|
selectBlock,
|
|
@@ -254,6 +207,9 @@ function Navigation( {
|
|
|
254
207
|
hasResolvedCanUserCreateNavigationMenu,
|
|
255
208
|
} = useNavigationMenu( ref );
|
|
256
209
|
|
|
210
|
+
const navMenuResolvedButMissing =
|
|
211
|
+
hasResolvedNavigationMenus && isNavigationMenuMissing;
|
|
212
|
+
|
|
257
213
|
// Attempt to retrieve and prioritize any existing navigation menu unless
|
|
258
214
|
// a specific ref is allocated or the user is explicitly creating a new menu. The aim is
|
|
259
215
|
// for the block to "just work" from a user perspective using existing data.
|
|
@@ -350,27 +306,6 @@ function Navigation( {
|
|
|
350
306
|
{ __unstableIsDisabled: hasBlockOverlay }
|
|
351
307
|
);
|
|
352
308
|
|
|
353
|
-
const overlayClassnames = classnames( {
|
|
354
|
-
'has-text-color':
|
|
355
|
-
!! overlayTextColor.color || !! overlayTextColor?.class,
|
|
356
|
-
[ getColorClassName( 'color', overlayTextColor?.slug ) ]:
|
|
357
|
-
!! overlayTextColor?.slug,
|
|
358
|
-
'has-background':
|
|
359
|
-
!! overlayBackgroundColor.color || overlayBackgroundColor?.class,
|
|
360
|
-
[ getColorClassName(
|
|
361
|
-
'background-color',
|
|
362
|
-
overlayBackgroundColor?.slug
|
|
363
|
-
) ]: !! overlayBackgroundColor?.slug,
|
|
364
|
-
} );
|
|
365
|
-
|
|
366
|
-
const overlayStyles = {
|
|
367
|
-
color: ! overlayTextColor?.slug && overlayTextColor?.color,
|
|
368
|
-
backgroundColor:
|
|
369
|
-
! overlayBackgroundColor?.slug &&
|
|
370
|
-
overlayBackgroundColor?.color &&
|
|
371
|
-
overlayBackgroundColor.color,
|
|
372
|
-
};
|
|
373
|
-
|
|
374
309
|
// Turn on contrast checker for web only since it's not supported on mobile yet.
|
|
375
310
|
const enableContrastChecking = Platform.OS === 'web';
|
|
376
311
|
|
|
@@ -382,19 +317,13 @@ function Navigation( {
|
|
|
382
317
|
] = useState();
|
|
383
318
|
const [ detectedOverlayColor, setDetectedOverlayColor ] = useState();
|
|
384
319
|
|
|
385
|
-
const
|
|
386
|
-
showClassicMenuConversionErrorNotice,
|
|
387
|
-
hideClassicMenuConversionErrorNotice,
|
|
388
|
-
] = useNavigationNotice( {
|
|
389
|
-
name: 'block-library/core/navigation/classic-menu-conversion/error',
|
|
390
|
-
} );
|
|
391
|
-
|
|
392
|
-
function handleUpdateMenu( menuId ) {
|
|
320
|
+
const handleUpdateMenu = ( menuId ) => {
|
|
393
321
|
setRef( menuId );
|
|
394
322
|
selectBlock( clientId );
|
|
395
|
-
}
|
|
323
|
+
};
|
|
396
324
|
|
|
397
325
|
useEffect( () => {
|
|
326
|
+
hideClassicMenuConversionNotice();
|
|
398
327
|
if ( classicMenuConversionStatus === CLASSIC_MENU_CONVERSION_PENDING ) {
|
|
399
328
|
speak( __( 'Classic menu importing.' ) );
|
|
400
329
|
}
|
|
@@ -404,13 +333,15 @@ function Navigation( {
|
|
|
404
333
|
classicMenuConversionResult
|
|
405
334
|
) {
|
|
406
335
|
handleUpdateMenu( classicMenuConversionResult?.id );
|
|
407
|
-
|
|
408
|
-
|
|
336
|
+
showClassicMenuConversionNotice(
|
|
337
|
+
__( 'Classic menu imported successfully.' )
|
|
338
|
+
);
|
|
409
339
|
}
|
|
410
340
|
|
|
411
341
|
if ( classicMenuConversionStatus === CLASSIC_MENU_CONVERSION_ERROR ) {
|
|
412
|
-
|
|
413
|
-
|
|
342
|
+
showClassicMenuConversionNotice(
|
|
343
|
+
__( 'Classic menu import failed.' )
|
|
344
|
+
);
|
|
414
345
|
}
|
|
415
346
|
}, [
|
|
416
347
|
classicMenuConversionStatus,
|
|
@@ -448,35 +379,23 @@ function Navigation( {
|
|
|
448
379
|
}
|
|
449
380
|
} );
|
|
450
381
|
|
|
451
|
-
const [ showCantEditNotice, hideCantEditNotice ] = useNavigationNotice( {
|
|
452
|
-
name: 'block-library/core/navigation/permissions/update',
|
|
453
|
-
message: __(
|
|
454
|
-
'You do not have permission to edit this Menu. Any changes made will not be saved.'
|
|
455
|
-
),
|
|
456
|
-
} );
|
|
457
|
-
|
|
458
|
-
const [ showCantCreateNotice, hideCantCreateNotice ] = useNavigationNotice(
|
|
459
|
-
{
|
|
460
|
-
name: 'block-library/core/navigation/permissions/create',
|
|
461
|
-
message: __(
|
|
462
|
-
'You do not have permission to create Navigation Menus.'
|
|
463
|
-
),
|
|
464
|
-
}
|
|
465
|
-
);
|
|
466
|
-
|
|
467
382
|
useEffect( () => {
|
|
468
383
|
if ( ! isSelected && ! isInnerBlockSelected ) {
|
|
469
|
-
|
|
470
|
-
hideCantCreateNotice();
|
|
384
|
+
hideNavigationMenuPermissionsNotice();
|
|
471
385
|
}
|
|
472
386
|
|
|
473
387
|
if ( isSelected || isInnerBlockSelected ) {
|
|
474
388
|
if (
|
|
475
389
|
ref &&
|
|
390
|
+
! navMenuResolvedButMissing &&
|
|
476
391
|
hasResolvedCanUserUpdateNavigationMenu &&
|
|
477
392
|
! canUserUpdateNavigationMenu
|
|
478
393
|
) {
|
|
479
|
-
|
|
394
|
+
showNavigationMenuPermissionsNotice(
|
|
395
|
+
__(
|
|
396
|
+
'You do not have permission to edit this Menu. Any changes made will not be saved.'
|
|
397
|
+
)
|
|
398
|
+
);
|
|
480
399
|
}
|
|
481
400
|
|
|
482
401
|
if (
|
|
@@ -484,7 +403,11 @@ function Navigation( {
|
|
|
484
403
|
hasResolvedCanUserCreateNavigationMenu &&
|
|
485
404
|
! canUserCreateNavigationMenu
|
|
486
405
|
) {
|
|
487
|
-
|
|
406
|
+
showNavigationMenuPermissionsNotice(
|
|
407
|
+
__(
|
|
408
|
+
'You do not have permission to create Navigation Menus.'
|
|
409
|
+
)
|
|
410
|
+
);
|
|
488
411
|
}
|
|
489
412
|
}
|
|
490
413
|
}, [
|
|
@@ -500,24 +423,6 @@ function Navigation( {
|
|
|
500
423
|
const navigationSelectorRef = useRef();
|
|
501
424
|
const [ shouldFocusNavigationSelector, setShouldFocusNavigationSelector ] =
|
|
502
425
|
useState( false );
|
|
503
|
-
const handleSelectNavigation = useCallback(
|
|
504
|
-
( navPostOrClassicMenu ) => {
|
|
505
|
-
if ( ! navPostOrClassicMenu ) {
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
const isClassicMenu =
|
|
510
|
-
navPostOrClassicMenu.hasOwnProperty( 'auto_add' );
|
|
511
|
-
|
|
512
|
-
if ( isClassicMenu ) {
|
|
513
|
-
convert( navPostOrClassicMenu.id, navPostOrClassicMenu.name );
|
|
514
|
-
} else {
|
|
515
|
-
handleUpdateMenu( navPostOrClassicMenu.id );
|
|
516
|
-
}
|
|
517
|
-
setShouldFocusNavigationSelector( true );
|
|
518
|
-
},
|
|
519
|
-
[ convert, handleUpdateMenu ]
|
|
520
|
-
);
|
|
521
426
|
|
|
522
427
|
// Focus support after menu selection.
|
|
523
428
|
useEffect( () => {
|
|
@@ -702,8 +607,8 @@ function Navigation( {
|
|
|
702
607
|
isOpen={ isResponsiveMenuOpen }
|
|
703
608
|
isResponsive={ 'never' !== overlayMenu }
|
|
704
609
|
isHiddenByDefault={ 'always' === overlayMenu }
|
|
705
|
-
|
|
706
|
-
|
|
610
|
+
overlayBackgroundColor={ overlayBackgroundColor }
|
|
611
|
+
overlayTextColor={ overlayTextColor }
|
|
707
612
|
>
|
|
708
613
|
<UnsavedInnerBlocks
|
|
709
614
|
blockProps={ blockProps }
|
|
@@ -720,7 +625,7 @@ function Navigation( {
|
|
|
720
625
|
// Switch to using the wp_navigation entity.
|
|
721
626
|
setRef( post.id );
|
|
722
627
|
|
|
723
|
-
|
|
628
|
+
showNavigationMenuStatusNotice(
|
|
724
629
|
__( `New Navigation Menu created.` )
|
|
725
630
|
);
|
|
726
631
|
} }
|
|
@@ -772,7 +677,14 @@ function Navigation( {
|
|
|
772
677
|
isResolvingCanUserCreateNavigationMenu={
|
|
773
678
|
isResolvingCanUserCreateNavigationMenu
|
|
774
679
|
}
|
|
775
|
-
|
|
680
|
+
onSelectNavigationMenu={ ( menuId ) => {
|
|
681
|
+
handleUpdateMenu( menuId );
|
|
682
|
+
setShouldFocusNavigationSelector( true );
|
|
683
|
+
} }
|
|
684
|
+
onSelectClassicMenu={ ( classicMenu ) => {
|
|
685
|
+
convert( classicMenu.id, classicMenu.name );
|
|
686
|
+
setShouldFocusNavigationSelector( true );
|
|
687
|
+
} }
|
|
776
688
|
onCreateEmpty={ () => createNavigationMenu( '', [] ) }
|
|
777
689
|
/>
|
|
778
690
|
</TagName>
|
|
@@ -781,7 +693,7 @@ function Navigation( {
|
|
|
781
693
|
|
|
782
694
|
return (
|
|
783
695
|
<EntityProvider kind="postType" type="wp_navigation" id={ ref }>
|
|
784
|
-
<RecursionProvider>
|
|
696
|
+
<RecursionProvider uniqueId={ recursionId }>
|
|
785
697
|
<BlockControls>
|
|
786
698
|
{ ! isDraftNavigationMenu && isEntityAvailable && (
|
|
787
699
|
<ToolbarGroup className="wp-block-navigation__toolbar-menu-selector">
|
|
@@ -789,7 +701,14 @@ function Navigation( {
|
|
|
789
701
|
ref={ navigationSelectorRef }
|
|
790
702
|
currentMenuId={ ref }
|
|
791
703
|
clientId={ clientId }
|
|
792
|
-
|
|
704
|
+
onSelectNavigationMenu={ ( menuId ) => {
|
|
705
|
+
handleUpdateMenu( menuId );
|
|
706
|
+
setShouldFocusNavigationSelector( true );
|
|
707
|
+
} }
|
|
708
|
+
onSelectClassicMenu={ ( classicMenu ) => {
|
|
709
|
+
convert( classicMenu.id, classicMenu.name );
|
|
710
|
+
setShouldFocusNavigationSelector( true );
|
|
711
|
+
} }
|
|
793
712
|
onCreateNew={ resetToEmptyBlock }
|
|
794
713
|
/* translators: %s: The name of a menu. */
|
|
795
714
|
actionLabel={ __( "Switch to '%s'" ) }
|
|
@@ -810,7 +729,7 @@ function Navigation( {
|
|
|
810
729
|
<NavigationMenuDeleteControl
|
|
811
730
|
onDelete={ ( deletedMenuTitle = '' ) => {
|
|
812
731
|
resetToEmptyBlock();
|
|
813
|
-
|
|
732
|
+
showNavigationMenuStatusNotice(
|
|
814
733
|
sprintf(
|
|
815
734
|
// translators: %s: the name of a menu (e.g. Header navigation).
|
|
816
735
|
__(
|
|
@@ -841,8 +760,8 @@ function Navigation( {
|
|
|
841
760
|
isOpen={ isResponsiveMenuOpen }
|
|
842
761
|
isResponsive={ isResponsive }
|
|
843
762
|
isHiddenByDefault={ 'always' === overlayMenu }
|
|
844
|
-
|
|
845
|
-
|
|
763
|
+
overlayBackgroundColor={ overlayBackgroundColor }
|
|
764
|
+
overlayTextColor={ overlayTextColor }
|
|
846
765
|
>
|
|
847
766
|
{ isEntityAvailable && (
|
|
848
767
|
<NavigationInnerBlocks
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { __, sprintf } from '@wordpress/i18n';
|
|
11
11
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
12
12
|
import { addQueryArgs } from '@wordpress/url';
|
|
13
|
-
import { forwardRef,
|
|
13
|
+
import { forwardRef, useMemo } from '@wordpress/element';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
@@ -21,7 +21,8 @@ import useNavigationEntities from '../use-navigation-entities';
|
|
|
21
21
|
function NavigationMenuSelector(
|
|
22
22
|
{
|
|
23
23
|
currentMenuId,
|
|
24
|
-
|
|
24
|
+
onSelectNavigationMenu,
|
|
25
|
+
onSelectClassicMenu,
|
|
25
26
|
onCreateNew,
|
|
26
27
|
showManageActions = false,
|
|
27
28
|
actionLabel,
|
|
@@ -43,24 +44,6 @@ function NavigationMenuSelector(
|
|
|
43
44
|
canSwitchNavigationMenu,
|
|
44
45
|
} = useNavigationMenu();
|
|
45
46
|
|
|
46
|
-
const handleSelect = useCallback(
|
|
47
|
-
( _onClose ) => ( selectedId ) => {
|
|
48
|
-
_onClose();
|
|
49
|
-
onSelect(
|
|
50
|
-
navigationMenus?.find( ( post ) => post.id === selectedId )
|
|
51
|
-
);
|
|
52
|
-
},
|
|
53
|
-
[ navigationMenus ]
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
const handleSelectClassic = useCallback(
|
|
57
|
-
( _onClose, menu ) => () => {
|
|
58
|
-
_onClose();
|
|
59
|
-
onSelect( menu );
|
|
60
|
-
},
|
|
61
|
-
[]
|
|
62
|
-
);
|
|
63
|
-
|
|
64
47
|
const menuChoices = useMemo( () => {
|
|
65
48
|
return (
|
|
66
49
|
navigationMenus?.map( ( { id, title } ) => {
|
|
@@ -83,7 +66,7 @@ function NavigationMenuSelector(
|
|
|
83
66
|
|
|
84
67
|
// Show the selector if:
|
|
85
68
|
// - has switch or create permissions and there are block or classic menus.
|
|
86
|
-
// - user has create or update
|
|
69
|
+
// - user has create or update permissions and component should show the menu actions.
|
|
87
70
|
const showSelectMenus =
|
|
88
71
|
( ( canSwitchNavigationMenu || canUserCreateNavigationMenu ) &&
|
|
89
72
|
( hasNavigationMenus || hasClassicMenus ) ) ||
|
|
@@ -107,7 +90,10 @@ function NavigationMenuSelector(
|
|
|
107
90
|
<MenuGroup label={ __( 'Menus' ) }>
|
|
108
91
|
<MenuItemsChoice
|
|
109
92
|
value={ currentMenuId }
|
|
110
|
-
onSelect={
|
|
93
|
+
onSelect={ ( menuId ) => {
|
|
94
|
+
onClose();
|
|
95
|
+
onSelectNavigationMenu( menuId );
|
|
96
|
+
} }
|
|
111
97
|
choices={ menuChoices }
|
|
112
98
|
/>
|
|
113
99
|
</MenuGroup>
|
|
@@ -118,10 +104,10 @@ function NavigationMenuSelector(
|
|
|
118
104
|
const label = decodeEntities( menu.name );
|
|
119
105
|
return (
|
|
120
106
|
<MenuItem
|
|
121
|
-
onClick={
|
|
122
|
-
onClose
|
|
123
|
-
menu
|
|
124
|
-
|
|
107
|
+
onClick={ () => {
|
|
108
|
+
onClose();
|
|
109
|
+
onSelectClassicMenu( menu );
|
|
110
|
+
} }
|
|
125
111
|
key={ menu.id }
|
|
126
112
|
aria-label={ sprintf(
|
|
127
113
|
createActionLabel,
|
|
@@ -20,7 +20,8 @@ export default function NavigationPlaceholder( {
|
|
|
20
20
|
clientId,
|
|
21
21
|
canUserCreateNavigationMenu = false,
|
|
22
22
|
isResolvingCanUserCreateNavigationMenu,
|
|
23
|
-
|
|
23
|
+
onSelectNavigationMenu,
|
|
24
|
+
onSelectClassicMenu,
|
|
24
25
|
onCreateEmpty,
|
|
25
26
|
} ) {
|
|
26
27
|
const { isResolvingMenus, hasResolvedMenus } = useNavigationEntities();
|
|
@@ -67,7 +68,8 @@ export default function NavigationPlaceholder( {
|
|
|
67
68
|
<NavigationMenuSelector
|
|
68
69
|
currentMenuId={ currentMenuId }
|
|
69
70
|
clientId={ clientId }
|
|
70
|
-
|
|
71
|
+
onSelectNavigationMenu={ onSelectNavigationMenu }
|
|
72
|
+
onSelectClassicMenu={ onSelectClassicMenu }
|
|
71
73
|
toggleProps={ {
|
|
72
74
|
variant: 'tertiary',
|
|
73
75
|
iconPosition: 'right',
|
|
@@ -9,6 +9,7 @@ import classnames from 'classnames';
|
|
|
9
9
|
import { close, Icon } from '@wordpress/icons';
|
|
10
10
|
import { Button } from '@wordpress/components';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
|
+
import { getColorClassName } from '@wordpress/block-editor';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Internal dependencies
|
|
@@ -22,21 +23,41 @@ export default function ResponsiveWrapper( {
|
|
|
22
23
|
isResponsive,
|
|
23
24
|
onToggle,
|
|
24
25
|
isHiddenByDefault,
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
overlayBackgroundColor,
|
|
27
|
+
overlayTextColor,
|
|
27
28
|
hasIcon,
|
|
28
29
|
} ) {
|
|
29
30
|
if ( ! isResponsive ) {
|
|
30
31
|
return children;
|
|
31
32
|
}
|
|
33
|
+
|
|
32
34
|
const responsiveContainerClasses = classnames(
|
|
33
35
|
'wp-block-navigation__responsive-container',
|
|
34
|
-
classNames,
|
|
35
36
|
{
|
|
37
|
+
'has-text-color':
|
|
38
|
+
!! overlayTextColor.color || !! overlayTextColor?.class,
|
|
39
|
+
[ getColorClassName( 'color', overlayTextColor?.slug ) ]:
|
|
40
|
+
!! overlayTextColor?.slug,
|
|
41
|
+
'has-background':
|
|
42
|
+
!! overlayBackgroundColor.color ||
|
|
43
|
+
overlayBackgroundColor?.class,
|
|
44
|
+
[ getColorClassName(
|
|
45
|
+
'background-color',
|
|
46
|
+
overlayBackgroundColor?.slug
|
|
47
|
+
) ]: !! overlayBackgroundColor?.slug,
|
|
36
48
|
'is-menu-open': isOpen,
|
|
37
49
|
'hidden-by-default': isHiddenByDefault,
|
|
38
50
|
}
|
|
39
51
|
);
|
|
52
|
+
|
|
53
|
+
const styles = {
|
|
54
|
+
color: ! overlayTextColor?.slug && overlayTextColor?.color,
|
|
55
|
+
backgroundColor:
|
|
56
|
+
! overlayBackgroundColor?.slug &&
|
|
57
|
+
overlayBackgroundColor?.color &&
|
|
58
|
+
overlayBackgroundColor.color,
|
|
59
|
+
};
|
|
60
|
+
|
|
40
61
|
const openButtonClasses = classnames(
|
|
41
62
|
'wp-block-navigation__responsive-container-open',
|
|
42
63
|
{ 'always-shown': isHiddenByDefault }
|
|
@@ -86,5 +86,9 @@ export default function useCreateNavigationMenu( clientId ) {
|
|
|
86
86
|
status,
|
|
87
87
|
value,
|
|
88
88
|
error,
|
|
89
|
+
isIdle: status === CREATE_NAVIGATION_MENU_IDLE,
|
|
90
|
+
isPending: status === CREATE_NAVIGATION_MENU_PENDING,
|
|
91
|
+
isSuccess: status === CREATE_NAVIGATION_MENU_SUCCESS,
|
|
92
|
+
isError: status === CREATE_NAVIGATION_MENU_ERROR,
|
|
89
93
|
};
|
|
90
94
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
6
|
+
|
|
7
|
+
const EMPTY_ARRAY = [];
|
|
8
|
+
|
|
9
|
+
export function useInnerBlocks( clientId ) {
|
|
10
|
+
return useSelect(
|
|
11
|
+
( select ) => {
|
|
12
|
+
const { getBlock, getBlocks, hasSelectedInnerBlock } =
|
|
13
|
+
select( blockEditorStore );
|
|
14
|
+
|
|
15
|
+
// This relies on the fact that `getBlock` won't return controlled
|
|
16
|
+
// inner blocks, while `getBlocks` does. It might be more stable to
|
|
17
|
+
// introduce a selector like `getUncontrolledInnerBlocks`, just in
|
|
18
|
+
// case `getBlock` is fixed.
|
|
19
|
+
const _uncontrolledInnerBlocks = getBlock( clientId ).innerBlocks;
|
|
20
|
+
|
|
21
|
+
const _hasUncontrolledInnerBlocks =
|
|
22
|
+
!! _uncontrolledInnerBlocks?.length;
|
|
23
|
+
const _controlledInnerBlocks = _hasUncontrolledInnerBlocks
|
|
24
|
+
? EMPTY_ARRAY
|
|
25
|
+
: getBlocks( clientId );
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
innerBlocks: _hasUncontrolledInnerBlocks
|
|
29
|
+
? _uncontrolledInnerBlocks
|
|
30
|
+
: _controlledInnerBlocks,
|
|
31
|
+
hasUncontrolledInnerBlocks: _hasUncontrolledInnerBlocks,
|
|
32
|
+
uncontrolledInnerBlocks: _uncontrolledInnerBlocks,
|
|
33
|
+
controlledInnerBlocks: _controlledInnerBlocks,
|
|
34
|
+
isInnerBlockSelected: hasSelectedInnerBlock( clientId, true ),
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
[ clientId ]
|
|
38
|
+
);
|
|
39
|
+
}
|