@wordpress/block-library 6.0.15 → 6.0.18
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/build/columns/index.js +1 -2
- package/build/columns/index.js.map +1 -1
- package/build/group/edit.native.js +1 -1
- package/build/group/edit.native.js.map +1 -1
- package/build/group/index.js +3 -1
- package/build/group/index.js.map +1 -1
- package/build/navigation/deprecated.js +1 -3
- package/build/navigation/deprecated.js.map +1 -1
- package/build/navigation/edit/index.js +100 -44
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +3 -2
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +15 -7
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +9 -7
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +3 -11
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-navigation-notice.js +54 -0
- package/build/navigation/edit/use-navigation-notice.js.map +1 -0
- package/build/navigation/index.js +2 -7
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +9 -2
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation/view.js +12 -7
- package/build/navigation/view.js.map +1 -1
- package/build/post-author/edit.js +1 -1
- package/build/post-author/edit.js.map +1 -1
- package/build/post-content/edit.js +1 -1
- package/build/post-content/edit.js.map +1 -1
- package/build/post-date/edit.js +1 -1
- package/build/post-date/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +1 -1
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +1 -1
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-template/edit.js +54 -13
- package/build/post-template/edit.js.map +1 -1
- package/build/post-title/edit.js +1 -1
- package/build/post-title/edit.js.map +1 -1
- package/build/site-logo/edit.js +117 -16
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-logo/index.js +5 -4
- package/build/site-logo/index.js.map +1 -1
- package/build/template-part/edit/index.js +7 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/index.js +25 -1
- package/build/template-part/index.js.map +1 -1
- package/build-module/columns/index.js +1 -2
- package/build-module/columns/index.js.map +1 -1
- package/build-module/group/edit.native.js +1 -1
- package/build-module/group/edit.native.js.map +1 -1
- package/build-module/group/index.js +3 -1
- package/build-module/group/index.js.map +1 -1
- package/build-module/navigation/deprecated.js +1 -3
- package/build-module/navigation/deprecated.js.map +1 -1
- package/build-module/navigation/edit/index.js +98 -44
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +3 -2
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +15 -7
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +9 -7
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +4 -13
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-navigation-notice.js +44 -0
- package/build-module/navigation/edit/use-navigation-notice.js.map +1 -0
- package/build-module/navigation/index.js +2 -7
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +9 -2
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation/view.js +12 -7
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/post-author/edit.js +1 -1
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-content/edit.js +1 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-date/edit.js +1 -1
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +1 -1
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +1 -1
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-template/edit.js +54 -15
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-title/edit.js +1 -1
- package/build-module/post-title/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +118 -17
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-logo/index.js +5 -4
- package/build-module/site-logo/index.js.map +1 -1
- package/build-module/template-part/edit/index.js +6 -1
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/index.js +25 -1
- package/build-module/template-part/index.js.map +1 -1
- package/build-style/common-rtl.css +10 -0
- package/build-style/common.css +10 -0
- package/build-style/editor-rtl.css +29 -17
- package/build-style/editor.css +29 -17
- package/build-style/navigation/editor-rtl.css +15 -6
- package/build-style/navigation/editor.css +15 -6
- package/build-style/navigation/style-rtl.css +55 -24
- package/build-style/navigation/style.css +55 -24
- package/build-style/post-comments/style-rtl.css +0 -1
- package/build-style/post-comments/style.css +0 -1
- package/build-style/site-logo/editor-rtl.css +1 -11
- package/build-style/site-logo/editor.css +1 -11
- package/build-style/site-logo/style-rtl.css +3 -1
- package/build-style/site-logo/style.css +3 -1
- package/build-style/style-rtl.css +68 -26
- package/build-style/style.css +68 -26
- package/package.json +14 -14
- package/src/columns/block.json +1 -2
- package/src/common.scss +12 -0
- package/src/editor.scss +15 -0
- package/src/gallery/index.php +1 -1
- package/src/group/block.json +3 -1
- package/src/group/edit.native.js +1 -1
- package/src/home-link/index.php +1 -1
- package/src/navigation/block.json +2 -13
- package/src/navigation/deprecated.js +0 -2
- package/src/navigation/edit/index.js +153 -55
- package/src/navigation/edit/navigation-menu-selector.js +19 -13
- package/src/navigation/edit/placeholder/index.js +40 -24
- package/src/navigation/edit/responsive-wrapper.js +10 -7
- package/src/navigation/edit/unsaved-inner-blocks.js +13 -25
- package/src/navigation/edit/use-navigation-notice.js +37 -0
- package/src/navigation/editor.scss +20 -8
- package/src/navigation/index.php +19 -8
- package/src/navigation/style.scss +81 -32
- package/src/navigation/use-navigation-menu.js +20 -0
- package/src/navigation/view.js +13 -7
- package/src/navigation-link/index.php +1 -1
- package/src/navigation-submenu/index.php +1 -1
- package/src/page-list/index.php +1 -1
- package/src/post-author/edit.js +1 -1
- package/src/post-comments/style.scss +0 -1
- package/src/post-content/edit.js +1 -1
- package/src/post-content/index.php +6 -1
- package/src/post-date/edit.js +1 -1
- package/src/post-excerpt/edit.js +1 -1
- package/src/post-excerpt/index.php +1 -1
- package/src/post-featured-image/edit.js +1 -1
- package/src/post-template/edit.js +54 -17
- package/src/post-title/edit.js +1 -1
- package/src/post-title/index.php +1 -1
- package/src/site-logo/block.json +5 -4
- package/src/site-logo/edit.js +130 -12
- package/src/site-logo/editor.scss +1 -15
- package/src/site-logo/index.php +17 -4
- package/src/site-logo/style.scss +3 -1
- package/src/template-part/edit/index.js +6 -1
- package/src/template-part/index.js +28 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-library",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.18",
|
|
4
4
|
"description": "Block library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"@wordpress/api-fetch": "^5.2.6",
|
|
38
38
|
"@wordpress/autop": "^3.2.3",
|
|
39
39
|
"@wordpress/blob": "^3.2.2",
|
|
40
|
-
"@wordpress/block-editor": "^8.0.
|
|
41
|
-
"@wordpress/blocks": "^11.1.
|
|
42
|
-
"@wordpress/components": "^19.
|
|
43
|
-
"@wordpress/compose": "^5.0.
|
|
44
|
-
"@wordpress/core-data": "^4.0.
|
|
45
|
-
"@wordpress/data": "^6.1.
|
|
40
|
+
"@wordpress/block-editor": "^8.0.13",
|
|
41
|
+
"@wordpress/blocks": "^11.1.5",
|
|
42
|
+
"@wordpress/components": "^19.2.0",
|
|
43
|
+
"@wordpress/compose": "^5.0.7",
|
|
44
|
+
"@wordpress/core-data": "^4.0.9",
|
|
45
|
+
"@wordpress/data": "^6.1.5",
|
|
46
46
|
"@wordpress/date": "^4.2.3",
|
|
47
47
|
"@wordpress/deprecated": "^3.2.3",
|
|
48
48
|
"@wordpress/dom": "^3.2.7",
|
|
@@ -52,16 +52,16 @@
|
|
|
52
52
|
"@wordpress/html-entities": "^3.2.3",
|
|
53
53
|
"@wordpress/i18n": "^4.2.4",
|
|
54
54
|
"@wordpress/icons": "^6.1.1",
|
|
55
|
-
"@wordpress/interface": "^4.1.
|
|
55
|
+
"@wordpress/interface": "^4.1.15",
|
|
56
56
|
"@wordpress/is-shallow-equal": "^4.2.1",
|
|
57
57
|
"@wordpress/keycodes": "^3.2.4",
|
|
58
|
-
"@wordpress/notices": "^3.2.
|
|
58
|
+
"@wordpress/notices": "^3.2.8",
|
|
59
59
|
"@wordpress/primitives": "^3.0.4",
|
|
60
|
-
"@wordpress/reusable-blocks": "^3.0.
|
|
61
|
-
"@wordpress/rich-text": "^5.0.
|
|
62
|
-
"@wordpress/server-side-render": "^3.0.
|
|
60
|
+
"@wordpress/reusable-blocks": "^3.0.19",
|
|
61
|
+
"@wordpress/rich-text": "^5.0.7",
|
|
62
|
+
"@wordpress/server-side-render": "^3.0.17",
|
|
63
63
|
"@wordpress/url": "^3.3.1",
|
|
64
|
-
"@wordpress/viewport": "^4.0.
|
|
64
|
+
"@wordpress/viewport": "^4.0.7",
|
|
65
65
|
"classnames": "^2.3.1",
|
|
66
66
|
"colord": "^2.7.0",
|
|
67
67
|
"fast-average-color": "4.3.0",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"publishConfig": {
|
|
74
74
|
"access": "public"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "f70f4664ac641bd107481c5c67ee6f5556a0a381"
|
|
77
77
|
}
|
package/src/columns/block.json
CHANGED
package/src/common.scss
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
@include background-colors-deprecated();
|
|
7
7
|
@include foreground-colors-deprecated();
|
|
8
8
|
@include gradient-colors-deprecated();
|
|
9
|
+
// This CSS Custom Properties aren't used anymore as defaults,
|
|
10
|
+
// but we still need to keep them for backward compatibility.
|
|
11
|
+
--wp--preset--font-size--normal: 16px;
|
|
12
|
+
--wp--preset--font-size--huge: 42px;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
// Font sizes (not used now, kept because of backward compatibility).
|
|
@@ -17,6 +21,14 @@
|
|
|
17
21
|
font-size: 2.625em;
|
|
18
22
|
}
|
|
19
23
|
|
|
24
|
+
.has-normal-font-size {
|
|
25
|
+
font-size: var(--wp--preset--font-size--normal) !important;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.has-huge-font-size {
|
|
29
|
+
font-size: var(--wp--preset--font-size--huge) !important;
|
|
30
|
+
}
|
|
31
|
+
|
|
20
32
|
// Text alignments.
|
|
21
33
|
.has-text-align-center {
|
|
22
34
|
text-align: center;
|
package/src/editor.scss
CHANGED
|
@@ -50,6 +50,13 @@
|
|
|
50
50
|
@include gradient-colors-deprecated();
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
// This CSS Custom Properties aren't used anymore as defaults,
|
|
54
|
+
// but we still need to keep them for backward compatibility.
|
|
55
|
+
.editor-styles-wrapper {
|
|
56
|
+
--wp--preset--font-size--normal: 16px;
|
|
57
|
+
--wp--preset--font-size--huge: 42px;
|
|
58
|
+
}
|
|
59
|
+
|
|
53
60
|
// Font sizes (not used now, kept because of backward compatibility).
|
|
54
61
|
//
|
|
55
62
|
// The reason we add the editor class wrapper here is
|
|
@@ -62,6 +69,14 @@
|
|
|
62
69
|
font-size: 42px;
|
|
63
70
|
}
|
|
64
71
|
|
|
72
|
+
.editor-styles-wrapper .has-normal-font-size {
|
|
73
|
+
font-size: var(--wp--preset--font-size--normal) !important;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.editor-styles-wrapper .has-huge-font-size {
|
|
77
|
+
font-size: var(--wp--preset--font-size--huge) !important;
|
|
78
|
+
}
|
|
79
|
+
|
|
65
80
|
/**
|
|
66
81
|
* Editor Normalization Styles
|
|
67
82
|
*
|
package/src/gallery/index.php
CHANGED
package/src/group/block.json
CHANGED
package/src/group/edit.native.js
CHANGED
|
@@ -120,7 +120,7 @@ export default compose( [
|
|
|
120
120
|
const { innerBlocks } = block;
|
|
121
121
|
const selectedBlockClientId = getSelectedBlockClientId();
|
|
122
122
|
const totalInnerBlocks = innerBlocks.length - 1;
|
|
123
|
-
const blockIndex = getBlockIndex( selectedBlockClientId
|
|
123
|
+
const blockIndex = getBlockIndex( selectedBlockClientId );
|
|
124
124
|
isLastInnerBlockSelected = totalInnerBlocks === blockIndex;
|
|
125
125
|
}
|
|
126
126
|
|
package/src/home-link/index.php
CHANGED
|
@@ -79,7 +79,7 @@ function block_core_home_link_build_css_font_sizes( $context ) {
|
|
|
79
79
|
$font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
|
|
80
80
|
} elseif ( $has_custom_font_size ) {
|
|
81
81
|
// Add the custom font size inline style.
|
|
82
|
-
$font_sizes['inline_styles'] = sprintf( 'font-size: %
|
|
82
|
+
$font_sizes['inline_styles'] = sprintf( 'font-size: %s;', $context['style']['typography']['fontSize'] );
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
return $font_sizes;
|
|
@@ -98,24 +98,13 @@
|
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
100
|
"spacing": {
|
|
101
|
-
"
|
|
102
|
-
"units": [
|
|
103
|
-
"px",
|
|
104
|
-
"em",
|
|
105
|
-
"rem",
|
|
106
|
-
"vh",
|
|
107
|
-
"vw"
|
|
108
|
-
],
|
|
109
|
-
"__experimentalDefaultControls": {
|
|
110
|
-
"blockGap": true
|
|
111
|
-
}
|
|
101
|
+
"units": [ "px", "em", "rem", "vh", "vw" ]
|
|
112
102
|
},
|
|
113
103
|
"__experimentalLayout": {
|
|
114
104
|
"allowSwitching": false,
|
|
115
105
|
"allowInheriting": false,
|
|
116
106
|
"default": {
|
|
117
|
-
"type": "flex"
|
|
118
|
-
"setCascadingProperties": true
|
|
107
|
+
"type": "flex"
|
|
119
108
|
}
|
|
120
109
|
}
|
|
121
110
|
},
|
|
@@ -43,7 +43,6 @@ const migrateWithLayout = ( attributes ) => {
|
|
|
43
43
|
Object.assign( updatedAttributes, {
|
|
44
44
|
layout: {
|
|
45
45
|
type: 'flex',
|
|
46
|
-
setCascadingProperties: 'true',
|
|
47
46
|
...( itemsJustification && {
|
|
48
47
|
justifyContent: itemsJustification,
|
|
49
48
|
} ),
|
|
@@ -135,7 +134,6 @@ const v6 = {
|
|
|
135
134
|
allowInheriting: false,
|
|
136
135
|
default: {
|
|
137
136
|
type: 'flex',
|
|
138
|
-
setCascadingProperties: true,
|
|
139
137
|
},
|
|
140
138
|
},
|
|
141
139
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import noop from 'lodash';
|
|
5
|
+
import { noop } from 'lodash';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
@@ -27,7 +27,8 @@ import {
|
|
|
27
27
|
Warning,
|
|
28
28
|
} from '@wordpress/block-editor';
|
|
29
29
|
import { EntityProvider, useEntityProp } from '@wordpress/core-data';
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
|
|
31
32
|
import {
|
|
32
33
|
PanelBody,
|
|
33
34
|
ToggleControl,
|
|
@@ -52,6 +53,9 @@ import NavigationMenuSelector from './navigation-menu-selector';
|
|
|
52
53
|
import NavigationMenuNameControl from './navigation-menu-name-control';
|
|
53
54
|
import UnsavedInnerBlocks from './unsaved-inner-blocks';
|
|
54
55
|
import NavigationMenuDeleteControl from './navigation-menu-delete-control';
|
|
56
|
+
import useNavigationNotice from './use-navigation-notice';
|
|
57
|
+
|
|
58
|
+
const EMPTY_ARRAY = [];
|
|
55
59
|
|
|
56
60
|
function getComputedStyle( node ) {
|
|
57
61
|
return node.ownerDocument.defaultView.getComputedStyle( node );
|
|
@@ -107,7 +111,11 @@ function Navigation( {
|
|
|
107
111
|
openSubmenusOnClick,
|
|
108
112
|
overlayMenu,
|
|
109
113
|
showSubmenuIcon,
|
|
110
|
-
layout: {
|
|
114
|
+
layout: {
|
|
115
|
+
justifyContent,
|
|
116
|
+
orientation = 'horizontal',
|
|
117
|
+
flexWrap = 'wrap',
|
|
118
|
+
} = {},
|
|
111
119
|
} = attributes;
|
|
112
120
|
|
|
113
121
|
let areaMenu,
|
|
@@ -128,6 +136,7 @@ function Navigation( {
|
|
|
128
136
|
|
|
129
137
|
const ref = navigationArea ? navigationAreaMenu : attributes.ref;
|
|
130
138
|
|
|
139
|
+
const registry = useRegistry();
|
|
131
140
|
const setRef = useCallback(
|
|
132
141
|
( postId ) => {
|
|
133
142
|
setAttributes( { ref: postId } );
|
|
@@ -142,19 +151,41 @@ function Navigation( {
|
|
|
142
151
|
`navigationMenu/${ ref }`
|
|
143
152
|
);
|
|
144
153
|
|
|
145
|
-
const {
|
|
154
|
+
const {
|
|
155
|
+
hasUncontrolledInnerBlocks,
|
|
156
|
+
uncontrolledInnerBlocks,
|
|
157
|
+
isInnerBlockSelected,
|
|
158
|
+
} = useSelect(
|
|
146
159
|
( select ) => {
|
|
147
|
-
const { getBlocks, hasSelectedInnerBlock } = select(
|
|
160
|
+
const { getBlock, getBlocks, hasSelectedInnerBlock } = select(
|
|
148
161
|
blockEditorStore
|
|
149
162
|
);
|
|
163
|
+
|
|
164
|
+
// This relies on the fact that `getBlock` won't return controlled
|
|
165
|
+
// inner blocks, while `getBlocks` does. It might be more stable to
|
|
166
|
+
// introduce a selector like `getUncontrolledInnerBlocks`, just in
|
|
167
|
+
// case `getBlock` is fixed.
|
|
168
|
+
const _uncontrolledInnerBlocks = getBlock( clientId ).innerBlocks;
|
|
169
|
+
const _hasUncontrolledInnerBlocks =
|
|
170
|
+
_uncontrolledInnerBlocks?.length;
|
|
171
|
+
const _controlledInnerBlocks = _hasUncontrolledInnerBlocks
|
|
172
|
+
? EMPTY_ARRAY
|
|
173
|
+
: getBlocks( clientId );
|
|
174
|
+
const innerBlocks = _hasUncontrolledInnerBlocks
|
|
175
|
+
? _uncontrolledInnerBlocks
|
|
176
|
+
: _controlledInnerBlocks;
|
|
177
|
+
|
|
150
178
|
return {
|
|
151
|
-
|
|
179
|
+
hasSubmenus: !! innerBlocks.find(
|
|
180
|
+
( block ) => block.name === 'core/navigation-submenu'
|
|
181
|
+
),
|
|
182
|
+
hasUncontrolledInnerBlocks: _hasUncontrolledInnerBlocks,
|
|
183
|
+
uncontrolledInnerBlocks: _uncontrolledInnerBlocks,
|
|
152
184
|
isInnerBlockSelected: hasSelectedInnerBlock( clientId, true ),
|
|
153
185
|
};
|
|
154
186
|
},
|
|
155
187
|
[ clientId ]
|
|
156
188
|
);
|
|
157
|
-
const hasExistingNavItems = !! innerBlocks.length;
|
|
158
189
|
const {
|
|
159
190
|
replaceInnerBlocks,
|
|
160
191
|
selectBlock,
|
|
@@ -166,10 +197,10 @@ function Navigation( {
|
|
|
166
197
|
setHasSavedUnsavedInnerBlocks,
|
|
167
198
|
] = useState( false );
|
|
168
199
|
|
|
169
|
-
const isWithinUnassignedArea = navigationArea && ! ref;
|
|
200
|
+
const isWithinUnassignedArea = !! navigationArea && ! ref;
|
|
170
201
|
|
|
171
202
|
const [ isPlaceholderShown, setIsPlaceholderShown ] = useState(
|
|
172
|
-
!
|
|
203
|
+
! hasUncontrolledInnerBlocks || isWithinUnassignedArea
|
|
173
204
|
);
|
|
174
205
|
|
|
175
206
|
const [ isResponsiveMenuOpen, setResponsiveMenuVisibility ] = useState(
|
|
@@ -183,6 +214,12 @@ function Navigation( {
|
|
|
183
214
|
hasResolvedNavigationMenus,
|
|
184
215
|
navigationMenus,
|
|
185
216
|
navigationMenu,
|
|
217
|
+
canUserUpdateNavigationEntity,
|
|
218
|
+
hasResolvedCanUserUpdateNavigationEntity,
|
|
219
|
+
canUserDeleteNavigationEntity,
|
|
220
|
+
hasResolvedCanUserDeleteNavigationEntity,
|
|
221
|
+
canUserCreateNavigation,
|
|
222
|
+
hasResolvedCanUserCreateNavigation,
|
|
186
223
|
} = useNavigationMenu( ref );
|
|
187
224
|
|
|
188
225
|
const navRef = useRef();
|
|
@@ -200,6 +237,10 @@ function Navigation( {
|
|
|
200
237
|
className: classnames( className, {
|
|
201
238
|
'items-justified-right': justifyContent === 'right',
|
|
202
239
|
'items-justified-space-between': justifyContent === 'space-between',
|
|
240
|
+
'items-justified-left': justifyContent === 'left',
|
|
241
|
+
'items-justified-center': justifyContent === 'center',
|
|
242
|
+
'is-vertical': orientation === 'vertical',
|
|
243
|
+
'no-wrap': flexWrap === 'nowrap',
|
|
203
244
|
'is-responsive': 'never' !== overlayMenu,
|
|
204
245
|
'has-text-color': !! textColor.color || !! textColor?.class,
|
|
205
246
|
[ getColorClassName(
|
|
@@ -270,7 +311,7 @@ function Navigation( {
|
|
|
270
311
|
setDetectedColor,
|
|
271
312
|
setDetectedBackgroundColor
|
|
272
313
|
);
|
|
273
|
-
const subMenuElement = navRef.current
|
|
314
|
+
const subMenuElement = navRef.current?.querySelector(
|
|
274
315
|
'[data-type="core/navigation-link"] [data-type="core/navigation-link"]'
|
|
275
316
|
);
|
|
276
317
|
if ( subMenuElement ) {
|
|
@@ -287,49 +328,105 @@ function Navigation( {
|
|
|
287
328
|
setIsPlaceholderShown( ! isEntityAvailable );
|
|
288
329
|
}, [ isEntityAvailable ] );
|
|
289
330
|
|
|
290
|
-
|
|
291
|
-
|
|
331
|
+
const [ showCantEditNotice, hideCantEditNotice ] = useNavigationNotice( {
|
|
332
|
+
name: 'block-library/core/navigation/permissions/update',
|
|
333
|
+
message: __(
|
|
334
|
+
'You do not have permission to edit this Menu. Any changes made will not be saved.'
|
|
335
|
+
),
|
|
336
|
+
} );
|
|
337
|
+
|
|
338
|
+
const [ showCantCreateNotice, hideCantCreateNotice ] = useNavigationNotice(
|
|
339
|
+
{
|
|
340
|
+
name: 'block-library/core/navigation/permissions/create',
|
|
341
|
+
message: __(
|
|
342
|
+
'You do not have permission to create Navigation Menus.'
|
|
343
|
+
),
|
|
344
|
+
}
|
|
345
|
+
);
|
|
346
|
+
|
|
292
347
|
useEffect( () => {
|
|
293
|
-
if (
|
|
294
|
-
|
|
348
|
+
if ( ! isSelected && ! isInnerBlockSelected ) {
|
|
349
|
+
hideCantEditNotice();
|
|
350
|
+
hideCantCreateNotice();
|
|
295
351
|
}
|
|
296
|
-
// innerBlocks are intentionally not listed as deps. This function is only concerned
|
|
297
|
-
// with the snapshot from the time when ref became undefined.
|
|
298
|
-
}, [ clientId, ref, innerBlocks ] );
|
|
299
352
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
353
|
+
if ( isSelected || isInnerBlockSelected ) {
|
|
354
|
+
if (
|
|
355
|
+
hasResolvedCanUserUpdateNavigationEntity &&
|
|
356
|
+
! canUserUpdateNavigationEntity
|
|
357
|
+
) {
|
|
358
|
+
showCantEditNotice();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (
|
|
362
|
+
! ref &&
|
|
363
|
+
hasResolvedCanUserCreateNavigation &&
|
|
364
|
+
! canUserCreateNavigation
|
|
365
|
+
) {
|
|
366
|
+
showCantCreateNotice();
|
|
367
|
+
}
|
|
303
368
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
369
|
+
}, [
|
|
370
|
+
isSelected,
|
|
371
|
+
isInnerBlockSelected,
|
|
372
|
+
canUserUpdateNavigationEntity,
|
|
373
|
+
hasResolvedCanUserUpdateNavigationEntity,
|
|
374
|
+
canUserCreateNavigation,
|
|
375
|
+
hasResolvedCanUserCreateNavigation,
|
|
376
|
+
ref,
|
|
377
|
+
] );
|
|
307
378
|
|
|
308
|
-
|
|
309
|
-
|
|
379
|
+
const startWithEmptyMenu = useCallback( () => {
|
|
380
|
+
registry.batch( () => {
|
|
381
|
+
if ( navigationArea ) {
|
|
382
|
+
setAreaMenu( 0 );
|
|
383
|
+
}
|
|
384
|
+
setAttributes( {
|
|
385
|
+
ref: undefined,
|
|
386
|
+
} );
|
|
387
|
+
if ( ! ref ) {
|
|
388
|
+
replaceInnerBlocks( clientId, [] );
|
|
389
|
+
}
|
|
390
|
+
setIsPlaceholderShown( true );
|
|
391
|
+
} );
|
|
392
|
+
}, [ clientId, ref ] );
|
|
310
393
|
|
|
311
394
|
// If the block has inner blocks, but no menu id, this was an older
|
|
312
395
|
// navigation block added before the block used a wp_navigation entity.
|
|
313
396
|
// Either this block was saved in the content or inserted by a pattern.
|
|
314
397
|
// Consider this 'unsaved'. Offer an uncontrolled version of inner blocks,
|
|
315
398
|
// that automatically saves the menu.
|
|
316
|
-
const hasUnsavedBlocks =
|
|
317
|
-
hasExistingNavItems && ! isEntityAvailable && ! isWithinUnassignedArea;
|
|
399
|
+
const hasUnsavedBlocks = hasUncontrolledInnerBlocks && ! isEntityAvailable;
|
|
318
400
|
if ( hasUnsavedBlocks ) {
|
|
319
401
|
return (
|
|
320
|
-
<
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
402
|
+
<nav { ...blockProps }>
|
|
403
|
+
<ResponsiveWrapper
|
|
404
|
+
id={ clientId }
|
|
405
|
+
onToggle={ setResponsiveMenuVisibility }
|
|
406
|
+
isOpen={ isResponsiveMenuOpen }
|
|
407
|
+
isResponsive={ 'never' !== overlayMenu }
|
|
408
|
+
isHiddenByDefault={ 'always' === overlayMenu }
|
|
409
|
+
classNames={ overlayClassnames }
|
|
410
|
+
styles={ overlayStyles }
|
|
411
|
+
>
|
|
412
|
+
<UnsavedInnerBlocks
|
|
413
|
+
blockProps={ blockProps }
|
|
414
|
+
blocks={ uncontrolledInnerBlocks }
|
|
415
|
+
clientId={ clientId }
|
|
416
|
+
navigationMenus={ navigationMenus }
|
|
417
|
+
hasSelection={ isSelected || isInnerBlockSelected }
|
|
418
|
+
hasSavedUnsavedInnerBlocks={
|
|
419
|
+
hasSavedUnsavedInnerBlocks
|
|
420
|
+
}
|
|
421
|
+
onSave={ ( post ) => {
|
|
422
|
+
// Set some state used as a guard to prevent the creation of multiple posts.
|
|
423
|
+
setHasSavedUnsavedInnerBlocks( true );
|
|
424
|
+
// Switch to using the wp_navigation entity.
|
|
425
|
+
setRef( post.id );
|
|
426
|
+
} }
|
|
427
|
+
/>
|
|
428
|
+
</ResponsiveWrapper>
|
|
429
|
+
</nav>
|
|
333
430
|
);
|
|
334
431
|
}
|
|
335
432
|
|
|
@@ -382,6 +479,7 @@ function Navigation( {
|
|
|
382
479
|
onClose();
|
|
383
480
|
} }
|
|
384
481
|
onCreateNew={ startWithEmptyMenu }
|
|
482
|
+
showCreate={ canUserCreateNavigation }
|
|
385
483
|
/>
|
|
386
484
|
) }
|
|
387
485
|
</ToolbarDropdownMenu>
|
|
@@ -492,18 +590,16 @@ function Navigation( {
|
|
|
492
590
|
</InspectorControls>
|
|
493
591
|
{ isEntityAvailable && (
|
|
494
592
|
<InspectorControls __experimentalGroup="advanced">
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
} }
|
|
506
|
-
/>
|
|
593
|
+
{ hasResolvedCanUserUpdateNavigationEntity &&
|
|
594
|
+
canUserUpdateNavigationEntity && (
|
|
595
|
+
<NavigationMenuNameControl />
|
|
596
|
+
) }
|
|
597
|
+
{ hasResolvedCanUserDeleteNavigationEntity &&
|
|
598
|
+
canUserDeleteNavigationEntity && (
|
|
599
|
+
<NavigationMenuDeleteControl
|
|
600
|
+
onDelete={ startWithEmptyMenu }
|
|
601
|
+
/>
|
|
602
|
+
) }
|
|
507
603
|
</InspectorControls>
|
|
508
604
|
) }
|
|
509
605
|
<nav { ...blockProps }>
|
|
@@ -521,11 +617,13 @@ function Navigation( {
|
|
|
521
617
|
hasResolvedNavigationMenus
|
|
522
618
|
}
|
|
523
619
|
clientId={ clientId }
|
|
620
|
+
canUserCreateNavigation={ canUserCreateNavigation }
|
|
524
621
|
/>
|
|
525
622
|
) }
|
|
526
|
-
{ !
|
|
527
|
-
|
|
528
|
-
|
|
623
|
+
{ ! hasResolvedCanUserCreateNavigation ||
|
|
624
|
+
( ! isEntityAvailable && ! isPlaceholderShown && (
|
|
625
|
+
<PlaceholderPreview isLoading />
|
|
626
|
+
) ) }
|
|
529
627
|
{ ! isPlaceholderShown && (
|
|
530
628
|
<ResponsiveWrapper
|
|
531
629
|
id={ clientId }
|
|
@@ -12,7 +12,11 @@ import { addQueryArgs } from '@wordpress/url';
|
|
|
12
12
|
*/
|
|
13
13
|
import useNavigationMenu from '../use-navigation-menu';
|
|
14
14
|
|
|
15
|
-
export default function NavigationMenuSelector( {
|
|
15
|
+
export default function NavigationMenuSelector( {
|
|
16
|
+
onSelect,
|
|
17
|
+
onCreateNew,
|
|
18
|
+
showCreate = false,
|
|
19
|
+
} ) {
|
|
16
20
|
const { navigationMenus } = useNavigationMenu();
|
|
17
21
|
const ref = useEntityId( 'postType', 'wp_navigation' );
|
|
18
22
|
|
|
@@ -42,18 +46,20 @@ export default function NavigationMenuSelector( { onSelect, onCreateNew } ) {
|
|
|
42
46
|
} ) }
|
|
43
47
|
/>
|
|
44
48
|
</MenuGroup>
|
|
45
|
-
|
|
46
|
-
<
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
{ showCreate && (
|
|
50
|
+
<MenuGroup>
|
|
51
|
+
<MenuItem onClick={ onCreateNew }>
|
|
52
|
+
{ __( 'Create new menu' ) }
|
|
53
|
+
</MenuItem>
|
|
54
|
+
<MenuItem
|
|
55
|
+
href={ addQueryArgs( 'edit.php', {
|
|
56
|
+
post_type: 'wp_navigation',
|
|
57
|
+
} ) }
|
|
58
|
+
>
|
|
59
|
+
{ __( 'Manage menus' ) }
|
|
60
|
+
</MenuItem>
|
|
61
|
+
</MenuGroup>
|
|
62
|
+
) }
|
|
57
63
|
</>
|
|
58
64
|
);
|
|
59
65
|
}
|