@wordpress/block-library 7.0.1 → 7.0.2
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/README.md +16 -0
- package/build/button/edit.native.js +2 -2
- package/build/button/edit.native.js.map +1 -1
- package/build/columns/index.js +12 -0
- package/build/columns/index.js.map +1 -1
- package/build/comment-author-avatar/edit.js +17 -4
- package/build/comment-author-avatar/edit.js.map +1 -1
- package/build/comment-template/edit.js +94 -36
- package/build/comment-template/edit.js.map +1 -1
- package/build/comment-template/hooks.js +175 -0
- package/build/comment-template/hooks.js.map +1 -0
- package/build/comment-template/index.js +1 -1
- package/build/comment-template/util.js.map +1 -1
- package/build/comments-pagination-next/index.js +1 -1
- package/build/comments-pagination-numbers/index.js +1 -1
- package/build/comments-query-loop/edit/comments-inspector-controls.js +20 -9
- package/build/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
- package/build/comments-query-loop/edit.js +1 -19
- package/build/comments-query-loop/edit.js.map +1 -1
- package/build/comments-query-loop/index.js +5 -0
- package/build/comments-query-loop/index.js.map +1 -1
- package/build/cover/edit.js +21 -22
- package/build/cover/edit.js.map +1 -1
- package/build/cover/edit.native.js +7 -5
- package/build/cover/edit.native.js.map +1 -1
- package/build/cover/overlay-color-settings.native.js +4 -3
- package/build/cover/overlay-color-settings.native.js.map +1 -1
- package/build/cover/transforms.js +4 -2
- package/build/cover/transforms.js.map +1 -1
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/edit.js +14 -2
- package/build/heading/edit.js.map +1 -1
- package/build/image/deprecated.js +89 -5
- package/build/image/deprecated.js.map +1 -1
- package/build/image/save.js +0 -7
- package/build/image/save.js.map +1 -1
- package/build/latest-posts/edit.js +1 -0
- package/build/latest-posts/edit.js.map +1 -1
- package/build/navigation/edit/index.js +17 -15
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +44 -27
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +8 -22
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +6 -6
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation-submenu/edit.js +41 -9
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/edit.js +11 -17
- package/build/page-list/edit.js.map +1 -1
- package/build/social-links/deprecated.js +1 -62
- package/build/social-links/deprecated.js.map +1 -1
- package/build/template-part/edit/index.js +36 -64
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/placeholder.js +64 -0
- package/build/template-part/edit/placeholder.js.map +1 -0
- package/build/template-part/edit/selection-modal.js +103 -0
- package/build/template-part/edit/selection-modal.js.map +1 -0
- package/build/template-part/edit/title-modal.js +54 -0
- package/build/template-part/edit/title-modal.js.map +1 -0
- package/build/template-part/edit/utils/hooks.js +156 -0
- package/build/template-part/edit/utils/hooks.js.map +1 -0
- package/build/template-part/index.js +3 -1
- package/build/template-part/index.js.map +1 -1
- package/build-module/button/edit.native.js +4 -4
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/columns/index.js +12 -0
- package/build-module/columns/index.js.map +1 -1
- package/build-module/comment-author-avatar/edit.js +18 -6
- package/build-module/comment-author-avatar/edit.js.map +1 -1
- package/build-module/comment-template/edit.js +95 -37
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/comment-template/hooks.js +156 -0
- package/build-module/comment-template/hooks.js.map +1 -0
- package/build-module/comment-template/index.js +1 -1
- package/build-module/comment-template/util.js.map +1 -1
- package/build-module/comments-pagination-next/index.js +1 -1
- package/build-module/comments-pagination-numbers/index.js +1 -1
- package/build-module/comments-query-loop/edit/comments-inspector-controls.js +20 -9
- package/build-module/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
- package/build-module/comments-query-loop/edit.js +2 -19
- package/build-module/comments-query-loop/edit.js.map +1 -1
- package/build-module/comments-query-loop/index.js +5 -0
- package/build-module/comments-query-loop/index.js.map +1 -1
- package/build-module/cover/edit.js +23 -24
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/cover/edit.native.js +10 -8
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/cover/overlay-color-settings.native.js +4 -4
- package/build-module/cover/overlay-color-settings.native.js.map +1 -1
- package/build-module/cover/transforms.js +4 -2
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/edit.js +15 -3
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/image/deprecated.js +90 -7
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/save.js +0 -7
- package/build-module/image/save.js.map +1 -1
- package/build-module/latest-posts/edit.js +1 -0
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/navigation/edit/index.js +17 -15
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +45 -27
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +8 -21
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +6 -6
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +41 -10
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/edit.js +12 -18
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/social-links/deprecated.js +1 -62
- package/build-module/social-links/deprecated.js.map +1 -1
- package/build-module/template-part/edit/index.js +37 -65
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/placeholder.js +52 -0
- package/build-module/template-part/edit/placeholder.js.map +1 -0
- package/build-module/template-part/edit/selection-modal.js +89 -0
- package/build-module/template-part/edit/selection-modal.js.map +1 -0
- package/build-module/template-part/edit/title-modal.js +46 -0
- package/build-module/template-part/edit/title-modal.js.map +1 -0
- package/build-module/template-part/edit/utils/hooks.js +135 -0
- package/build-module/template-part/edit/utils/hooks.js.map +1 -0
- package/build-module/template-part/index.js +2 -1
- package/build-module/template-part/index.js.map +1 -1
- package/build-style/comment-author-avatar/editor-rtl.css +83 -0
- package/build-style/comment-author-avatar/editor.css +83 -0
- package/build-style/cover/style-rtl.css +4 -0
- package/build-style/cover/style.css +4 -0
- package/build-style/editor-rtl.css +27 -81
- package/build-style/editor.css +27 -81
- package/build-style/image/editor-rtl.css +0 -16
- package/build-style/image/editor.css +0 -16
- package/build-style/image/style-rtl.css +2 -0
- package/build-style/image/style.css +2 -0
- package/build-style/navigation/style-rtl.css +14 -3
- package/build-style/navigation/style.css +14 -3
- package/build-style/page-list/editor-rtl.css +0 -9
- package/build-style/page-list/editor.css +0 -9
- package/build-style/style-rtl.css +20 -3
- package/build-style/style.css +20 -3
- package/build-style/template-part/editor-rtl.css +19 -56
- package/build-style/template-part/editor.css +19 -56
- package/package.json +15 -15
- package/src/archives/index.php +1 -1
- package/src/button/edit.native.js +3 -3
- package/src/columns/block.json +12 -0
- package/src/comment-author-avatar/edit.js +13 -8
- package/src/comment-author-avatar/editor.scss +7 -0
- package/src/comment-template/block.json +7 -1
- package/src/comment-template/edit.js +102 -40
- package/src/comment-template/hooks.js +151 -0
- package/src/comment-template/index.php +8 -0
- package/src/comment-template/util.js +1 -0
- package/src/comments-pagination-next/block.json +8 -1
- package/src/comments-pagination-next/index.php +6 -8
- package/src/comments-pagination-numbers/block.json +7 -1
- package/src/comments-pagination-numbers/index.php +3 -10
- package/src/comments-query-loop/block.json +5 -0
- package/src/comments-query-loop/edit/comments-inspector-controls.js +22 -4
- package/src/comments-query-loop/edit.js +1 -16
- package/src/cover/edit.js +15 -28
- package/src/cover/edit.native.js +15 -7
- package/src/cover/overlay-color-settings.native.js +3 -4
- package/src/cover/style.scss +4 -0
- package/src/cover/transforms.js +2 -0
- package/src/editor.scss +1 -0
- package/src/gallery/index.php +1 -8
- package/src/group/block.json +1 -0
- package/src/heading/edit.js +18 -5
- package/src/home-link/index.php +1 -19
- package/src/image/deprecated.js +105 -1
- package/src/image/editor.scss +0 -18
- package/src/image/save.js +0 -8
- package/src/image/style.scss +3 -0
- package/src/image/test/edit.native.js +0 -10
- package/src/latest-posts/edit.js +1 -0
- package/src/latest-posts/index.php +1 -1
- package/src/navigation/edit/index.js +25 -26
- package/src/navigation/edit/navigation-menu-selector.js +73 -28
- package/src/navigation/edit/placeholder/index.js +8 -32
- package/src/navigation/index.php +4 -4
- package/src/navigation/style.scss +22 -3
- package/src/navigation/use-navigation-menu.js +6 -6
- package/src/navigation-link/index.php +3 -22
- package/src/navigation-submenu/edit.js +50 -12
- package/src/navigation-submenu/index.php +3 -21
- package/src/page-list/edit.js +21 -25
- package/src/page-list/editor.scss +0 -10
- package/src/page-list/index.php +4 -4
- package/src/post-navigation-link/index.php +3 -3
- package/src/search/index.php +6 -3
- package/src/site-logo/index.php +1 -1
- package/src/social-links/deprecated.js +0 -59
- package/src/template-part/edit/index.js +61 -71
- package/src/template-part/edit/placeholder.js +78 -0
- package/src/template-part/edit/selection-modal.js +115 -0
- package/src/template-part/edit/title-modal.js +59 -0
- package/src/template-part/edit/utils/hooks.js +158 -0
- package/src/template-part/editor.scss +16 -74
- package/src/template-part/index.js +4 -1
- package/build/navigation/edit/existing-menus-options.js +0 -62
- package/build/navigation/edit/existing-menus-options.js.map +0 -1
- package/build/template-part/edit/placeholder/index.js +0 -141
- package/build/template-part/edit/placeholder/index.js.map +0 -1
- package/build/template-part/edit/placeholder/patterns-setup.js +0 -100
- package/build/template-part/edit/placeholder/patterns-setup.js.map +0 -1
- package/build/template-part/edit/selection/index.js +0 -45
- package/build/template-part/edit/selection/index.js.map +0 -1
- package/build/template-part/edit/selection/template-part-previews.js +0 -317
- package/build/template-part/edit/selection/template-part-previews.js.map +0 -1
- package/build-module/navigation/edit/existing-menus-options.js +0 -53
- package/build-module/navigation/edit/existing-menus-options.js.map +0 -1
- package/build-module/template-part/edit/placeholder/index.js +0 -124
- package/build-module/template-part/edit/placeholder/index.js.map +0 -1
- package/build-module/template-part/edit/placeholder/patterns-setup.js +0 -91
- package/build-module/template-part/edit/placeholder/patterns-setup.js.map +0 -1
- package/build-module/template-part/edit/selection/index.js +0 -35
- package/build-module/template-part/edit/selection/index.js.map +0 -1
- package/build-module/template-part/edit/selection/template-part-previews.js +0 -298
- package/build-module/template-part/edit/selection/template-part-previews.js.map +0 -1
- package/src/navigation/edit/existing-menus-options.js +0 -70
- package/src/template-part/edit/placeholder/index.js +0 -172
- package/src/template-part/edit/placeholder/patterns-setup.js +0 -124
- package/src/template-part/edit/selection/index.js +0 -37
- package/src/template-part/edit/selection/template-part-previews.js +0 -372
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { MenuGroup, MenuItem } from '@wordpress/components';
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
6
|
-
|
|
5
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
6
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
7
7
|
import { addQueryArgs } from '@wordpress/url';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -13,20 +13,27 @@ import useNavigationMenu from '../use-navigation-menu';
|
|
|
13
13
|
import useNavigationEntities from '../use-navigation-entities';
|
|
14
14
|
import useConvertClassicMenu from '../use-convert-classic-menu';
|
|
15
15
|
import useCreateNavigationMenu from './use-create-navigation-menu';
|
|
16
|
-
import ExistingMenusOptions from './existing-menus-options';
|
|
17
16
|
|
|
18
17
|
export default function NavigationMenuSelector( {
|
|
19
18
|
clientId,
|
|
20
19
|
onSelect,
|
|
21
20
|
onCreateNew,
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
showManageActions = false,
|
|
22
|
+
actionLabel,
|
|
24
23
|
} ) {
|
|
24
|
+
/* translators: %s: The name of a menu. */
|
|
25
|
+
const createActionLabel = __( "Create from '%s'" );
|
|
26
|
+
|
|
27
|
+
actionLabel = actionLabel || createActionLabel;
|
|
28
|
+
|
|
29
|
+
const { menus: classicMenus } = useNavigationEntities();
|
|
30
|
+
|
|
25
31
|
const {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
navigationMenus,
|
|
33
|
+
canUserCreateNavigationMenu,
|
|
34
|
+
canUserUpdateNavigationMenu,
|
|
35
|
+
canSwitchNavigationMenu,
|
|
36
|
+
} = useNavigationMenu();
|
|
30
37
|
|
|
31
38
|
const createNavigationMenu = useCreateNavigationMenu( clientId );
|
|
32
39
|
|
|
@@ -34,7 +41,7 @@ export default function NavigationMenuSelector( {
|
|
|
34
41
|
blocks,
|
|
35
42
|
navigationMenuTitle = null
|
|
36
43
|
) => {
|
|
37
|
-
if ( !
|
|
44
|
+
if ( ! canUserCreateNavigationMenu ) {
|
|
38
45
|
return;
|
|
39
46
|
}
|
|
40
47
|
|
|
@@ -49,9 +56,15 @@ export default function NavigationMenuSelector( {
|
|
|
49
56
|
onFinishMenuCreation
|
|
50
57
|
);
|
|
51
58
|
|
|
59
|
+
const hasNavigationMenus = !! navigationMenus?.length;
|
|
60
|
+
const hasClassicMenus = !! classicMenus?.length;
|
|
61
|
+
const showNavigationMenus = !! canSwitchNavigationMenu;
|
|
62
|
+
const showClassicMenus = !! canUserCreateNavigationMenu;
|
|
63
|
+
const hasManagePermissions =
|
|
64
|
+
canUserCreateNavigationMenu || canUserUpdateNavigationMenu;
|
|
52
65
|
const showSelectMenus =
|
|
53
|
-
(
|
|
54
|
-
(
|
|
66
|
+
( canSwitchNavigationMenu || canUserCreateNavigationMenu ) &&
|
|
67
|
+
( hasNavigationMenus || hasClassicMenus );
|
|
55
68
|
|
|
56
69
|
if ( ! showSelectMenus ) {
|
|
57
70
|
return null;
|
|
@@ -59,24 +72,56 @@ export default function NavigationMenuSelector( {
|
|
|
59
72
|
|
|
60
73
|
return (
|
|
61
74
|
<>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
{ showNavigationMenus && hasNavigationMenus && (
|
|
76
|
+
<MenuGroup label={ __( 'Menus' ) }>
|
|
77
|
+
{ navigationMenus.map( ( menu ) => {
|
|
78
|
+
const label = decodeEntities( menu.title.rendered );
|
|
79
|
+
return (
|
|
80
|
+
<MenuItem
|
|
81
|
+
onClick={ () => {
|
|
82
|
+
onSelect( menu );
|
|
83
|
+
} }
|
|
84
|
+
key={ menu.id }
|
|
85
|
+
aria-label={ sprintf( actionLabel, label ) }
|
|
86
|
+
>
|
|
87
|
+
{ label }
|
|
88
|
+
</MenuItem>
|
|
89
|
+
);
|
|
90
|
+
} ) }
|
|
91
|
+
</MenuGroup>
|
|
92
|
+
) }
|
|
93
|
+
{ showClassicMenus && hasClassicMenus && (
|
|
94
|
+
<MenuGroup label={ __( 'Classic Menus' ) }>
|
|
95
|
+
{ classicMenus.map( ( menu ) => {
|
|
96
|
+
const label = decodeEntities( menu.name );
|
|
97
|
+
return (
|
|
98
|
+
<MenuItem
|
|
99
|
+
onClick={ () => {
|
|
100
|
+
convertClassicMenuToBlocks(
|
|
101
|
+
menu.id,
|
|
102
|
+
menu.name
|
|
103
|
+
);
|
|
104
|
+
} }
|
|
105
|
+
key={ menu.id }
|
|
106
|
+
aria-label={ sprintf(
|
|
107
|
+
createActionLabel,
|
|
108
|
+
label
|
|
109
|
+
) }
|
|
110
|
+
>
|
|
111
|
+
{ label }
|
|
112
|
+
</MenuItem>
|
|
113
|
+
);
|
|
114
|
+
} ) }
|
|
115
|
+
</MenuGroup>
|
|
116
|
+
) }
|
|
74
117
|
|
|
75
|
-
{
|
|
118
|
+
{ showManageActions && hasManagePermissions && (
|
|
76
119
|
<MenuGroup label={ __( 'Tools' ) }>
|
|
77
|
-
|
|
78
|
-
{
|
|
79
|
-
|
|
120
|
+
{ canUserCreateNavigationMenu && (
|
|
121
|
+
<MenuItem onClick={ onCreateNew }>
|
|
122
|
+
{ __( 'Create new menu' ) }
|
|
123
|
+
</MenuItem>
|
|
124
|
+
) }
|
|
80
125
|
<MenuItem
|
|
81
126
|
href={ addQueryArgs( 'edit.php', {
|
|
82
127
|
post_type: 'wp_navigation',
|
|
@@ -13,15 +13,14 @@ import useNavigationEntities from '../../use-navigation-entities';
|
|
|
13
13
|
import PlaceholderPreview from './placeholder-preview';
|
|
14
14
|
import useNavigationMenu from '../../use-navigation-menu';
|
|
15
15
|
import useCreateNavigationMenu from '../use-create-navigation-menu';
|
|
16
|
-
import
|
|
17
|
-
import ExistingMenusOptions from '../existing-menus-options';
|
|
16
|
+
import NavigationMenuSelector from '../navigation-menu-selector';
|
|
18
17
|
|
|
19
18
|
export default function NavigationPlaceholder( {
|
|
20
19
|
clientId,
|
|
21
20
|
onFinish,
|
|
22
21
|
canSwitchNavigationMenu,
|
|
23
22
|
hasResolvedNavigationMenus,
|
|
24
|
-
|
|
23
|
+
canUserCreateNavigationMenu = false,
|
|
25
24
|
} ) {
|
|
26
25
|
const createNavigationMenu = useCreateNavigationMenu( clientId );
|
|
27
26
|
|
|
@@ -29,7 +28,7 @@ export default function NavigationPlaceholder( {
|
|
|
29
28
|
blocks,
|
|
30
29
|
navigationMenuTitle = null
|
|
31
30
|
) => {
|
|
32
|
-
if ( !
|
|
31
|
+
if ( ! canUserCreateNavigationMenu ) {
|
|
33
32
|
return;
|
|
34
33
|
}
|
|
35
34
|
|
|
@@ -40,11 +39,8 @@ export default function NavigationPlaceholder( {
|
|
|
40
39
|
onFinish( navigationMenu, blocks );
|
|
41
40
|
};
|
|
42
41
|
|
|
43
|
-
const convertClassicMenu = useConvertClassicMenu( onFinishMenuCreation );
|
|
44
|
-
|
|
45
42
|
const {
|
|
46
43
|
isResolvingPages,
|
|
47
|
-
menus,
|
|
48
44
|
isResolvingMenus,
|
|
49
45
|
hasMenus,
|
|
50
46
|
} = useNavigationEntities();
|
|
@@ -60,7 +56,7 @@ export default function NavigationPlaceholder( {
|
|
|
60
56
|
const hasNavigationMenus = !! navigationMenus?.length;
|
|
61
57
|
|
|
62
58
|
const showSelectMenus =
|
|
63
|
-
( canSwitchNavigationMenu ||
|
|
59
|
+
( canSwitchNavigationMenu || canUserCreateNavigationMenu ) &&
|
|
64
60
|
( hasNavigationMenus || hasMenus );
|
|
65
61
|
|
|
66
62
|
return (
|
|
@@ -94,29 +90,9 @@ export default function NavigationPlaceholder( {
|
|
|
94
90
|
popoverProps={ { isAlternate: true } }
|
|
95
91
|
>
|
|
96
92
|
{ () => (
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
navigationMenus={
|
|
102
|
-
navigationMenus
|
|
103
|
-
}
|
|
104
|
-
onSelectNavigationMenu={
|
|
105
|
-
onFinish
|
|
106
|
-
}
|
|
107
|
-
classicMenus={ menus }
|
|
108
|
-
onSelectClassicMenu={ ( {
|
|
109
|
-
id,
|
|
110
|
-
name,
|
|
111
|
-
} ) =>
|
|
112
|
-
convertClassicMenu(
|
|
113
|
-
id,
|
|
114
|
-
name
|
|
115
|
-
)
|
|
116
|
-
}
|
|
117
|
-
showClassicMenus={
|
|
118
|
-
canUserCreateNavigation
|
|
119
|
-
}
|
|
93
|
+
<NavigationMenuSelector
|
|
94
|
+
clientId={ clientId }
|
|
95
|
+
onSelect={ onFinish }
|
|
120
96
|
/>
|
|
121
97
|
) }
|
|
122
98
|
</DropdownMenu>
|
|
@@ -124,7 +100,7 @@ export default function NavigationPlaceholder( {
|
|
|
124
100
|
</>
|
|
125
101
|
) : undefined }
|
|
126
102
|
|
|
127
|
-
{
|
|
103
|
+
{ canUserCreateNavigationMenu && (
|
|
128
104
|
<Button
|
|
129
105
|
variant="tertiary"
|
|
130
106
|
onClick={ onCreateEmptyMenu }
|
package/src/navigation/index.php
CHANGED
|
@@ -515,7 +515,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
|
|
515
515
|
)
|
|
516
516
|
);
|
|
517
517
|
|
|
518
|
-
$modal_unique_id =
|
|
518
|
+
$modal_unique_id = wp_unique_id( 'modal-' );
|
|
519
519
|
|
|
520
520
|
// Determine whether or not navigation elements should be wrapped in the markup required to make it responsive,
|
|
521
521
|
// return early if they don't.
|
|
@@ -544,12 +544,12 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
|
|
544
544
|
$toggle_button_content = $should_display_icon_label ? $toggle_button_icon : 'Menu';
|
|
545
545
|
|
|
546
546
|
$responsive_container_markup = sprintf(
|
|
547
|
-
'<button aria-haspopup="true" aria-label="%3$s" class="%6$s" data-micromodal-trigger="
|
|
548
|
-
<div class="%5$s" style="%7$s" id="
|
|
547
|
+
'<button aria-haspopup="true" aria-label="%3$s" class="%6$s" data-micromodal-trigger="%1$s">%9$s</button>
|
|
548
|
+
<div class="%5$s" style="%7$s" id="%1$s">
|
|
549
549
|
<div class="wp-block-navigation__responsive-close" tabindex="-1" data-micromodal-close>
|
|
550
550
|
<div class="wp-block-navigation__responsive-dialog" aria-label="%8$s">
|
|
551
551
|
<button aria-label="%4$s" data-micromodal-close class="wp-block-navigation__responsive-container-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg></button>
|
|
552
|
-
<div class="wp-block-navigation__responsive-container-content" id="
|
|
552
|
+
<div class="wp-block-navigation__responsive-container-content" id="%1$s-content">
|
|
553
553
|
%2$s
|
|
554
554
|
</div>
|
|
555
555
|
</div>
|
|
@@ -85,7 +85,6 @@ $navigation-icon-size: 24px;
|
|
|
85
85
|
align-self: center; // This one affects nested submenu indicators.
|
|
86
86
|
line-height: 0;
|
|
87
87
|
display: inline-block;
|
|
88
|
-
vertical-align: middle;
|
|
89
88
|
font-size: inherit;
|
|
90
89
|
|
|
91
90
|
// Affect the button as well.
|
|
@@ -95,15 +94,18 @@ $navigation-icon-size: 24px;
|
|
|
95
94
|
border: none;
|
|
96
95
|
|
|
97
96
|
// Scale to font size.
|
|
98
|
-
margin-left: 0.25em;
|
|
99
97
|
width: 0.6em;
|
|
100
98
|
height: 0.6em;
|
|
99
|
+
margin-left: 0.25em;
|
|
101
100
|
|
|
102
101
|
svg {
|
|
103
102
|
display: inline-block;
|
|
104
103
|
stroke: currentColor;
|
|
105
104
|
width: inherit;
|
|
106
105
|
height: inherit;
|
|
106
|
+
|
|
107
|
+
// Position the arrow to balance with the the text.
|
|
108
|
+
margin-top: 0.075em;
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
111
|
|
|
@@ -216,6 +218,11 @@ $navigation-icon-size: 24px;
|
|
|
216
218
|
}
|
|
217
219
|
}
|
|
218
220
|
|
|
221
|
+
// Push inwards from right edge of submenu.
|
|
222
|
+
.wp-block-navigation__submenu-icon {
|
|
223
|
+
margin-right: 0.25em;
|
|
224
|
+
}
|
|
225
|
+
|
|
219
226
|
// Reset the submenu indicator for horizontal flyouts.
|
|
220
227
|
.wp-block-navigation__submenu-icon svg {
|
|
221
228
|
transform: rotate(-90deg);
|
|
@@ -245,7 +252,7 @@ $navigation-icon-size: 24px;
|
|
|
245
252
|
}
|
|
246
253
|
|
|
247
254
|
// Show submenus on click.
|
|
248
|
-
.wp-block-navigation-submenu__toggle[aria-expanded="true"]
|
|
255
|
+
.wp-block-navigation-submenu__toggle[aria-expanded="true"] ~ .wp-block-navigation__submenu-container {
|
|
249
256
|
visibility: visible;
|
|
250
257
|
overflow: visible;
|
|
251
258
|
opacity: 1;
|
|
@@ -300,6 +307,18 @@ button.wp-block-navigation-item__content {
|
|
|
300
307
|
cursor: pointer;
|
|
301
308
|
}
|
|
302
309
|
|
|
310
|
+
// When set to open on click, a button element is used.
|
|
311
|
+
// We pad it to include the arrow icon in the clickable area.
|
|
312
|
+
// The padding can be blanket for click, since you can't set click and hide the icon.
|
|
313
|
+
.wp-block-navigation-item.open-on-click .wp-block-navigation-submenu__toggle {
|
|
314
|
+
padding-right: 0.6em + 0.25em; // Same size as icon plus margin.
|
|
315
|
+
|
|
316
|
+
+ .wp-block-navigation__submenu-icon {
|
|
317
|
+
margin-left: -0.6em;
|
|
318
|
+
pointer-events: none; // Make the icon inert to allow click on the button.
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
303
322
|
|
|
304
323
|
/**
|
|
305
324
|
* Margins
|
|
@@ -65,22 +65,22 @@ export default function useNavigationMenu( ref ) {
|
|
|
65
65
|
),
|
|
66
66
|
navigationMenu,
|
|
67
67
|
navigationMenus,
|
|
68
|
-
|
|
68
|
+
canUserUpdateNavigationMenu: ref
|
|
69
69
|
? canUser( 'update', 'navigation', ref )
|
|
70
70
|
: undefined,
|
|
71
|
-
|
|
71
|
+
hasResolvedCanUserUpdateNavigationMenu: hasFinishedResolution(
|
|
72
72
|
'canUser',
|
|
73
73
|
[ 'update', 'navigation', ref ]
|
|
74
74
|
),
|
|
75
|
-
|
|
75
|
+
canUserDeleteNavigationMenu: ref
|
|
76
76
|
? canUser( 'delete', 'navigation', ref )
|
|
77
77
|
: undefined,
|
|
78
|
-
|
|
78
|
+
hasResolvedCanUserDeleteNavigationMenu: hasFinishedResolution(
|
|
79
79
|
'canUser',
|
|
80
80
|
[ 'delete', 'navigation', ref ]
|
|
81
81
|
),
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
canUserCreateNavigationMenu: canUser( 'create', 'navigation' ),
|
|
83
|
+
hasResolvedCanUserCreateNavigationMenu: hasFinishedResolution(
|
|
84
84
|
'canUser',
|
|
85
85
|
[ 'create', 'navigation' ]
|
|
86
86
|
),
|
|
@@ -193,37 +193,18 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
|
|
|
193
193
|
'<span class="wp-block-navigation-item__label">';
|
|
194
194
|
|
|
195
195
|
if ( isset( $attributes['label'] ) ) {
|
|
196
|
-
$html .=
|
|
197
|
-
$attributes['label'],
|
|
198
|
-
array(
|
|
199
|
-
'code' => array(),
|
|
200
|
-
'em' => array(),
|
|
201
|
-
'img' => array(
|
|
202
|
-
'scale' => array(),
|
|
203
|
-
'class' => array(),
|
|
204
|
-
'style' => array(),
|
|
205
|
-
'src' => array(),
|
|
206
|
-
'alt' => array(),
|
|
207
|
-
),
|
|
208
|
-
's' => array(),
|
|
209
|
-
'span' => array(
|
|
210
|
-
'style' => array(),
|
|
211
|
-
),
|
|
212
|
-
'strong' => array(),
|
|
213
|
-
)
|
|
214
|
-
);
|
|
196
|
+
$html .= wp_kses_post( $attributes['label'] );
|
|
215
197
|
}
|
|
216
198
|
|
|
217
199
|
$html .= '</span>';
|
|
200
|
+
$html .= '</a>';
|
|
201
|
+
// End anchor tag content.
|
|
218
202
|
|
|
219
203
|
if ( isset( $block->context['showSubmenuIcon'] ) && $block->context['showSubmenuIcon'] && $has_submenu ) {
|
|
220
204
|
// The submenu icon can be hidden by a CSS rule on the Navigation Block.
|
|
221
205
|
$html .= '<span class="wp-block-navigation__submenu-icon">' . block_core_navigation_link_render_submenu_icon() . '</span>';
|
|
222
206
|
}
|
|
223
207
|
|
|
224
|
-
$html .= '</a>';
|
|
225
|
-
// End anchor tag content.
|
|
226
|
-
|
|
227
208
|
if ( $has_submenu ) {
|
|
228
209
|
$inner_blocks_html = '';
|
|
229
210
|
foreach ( $block->inner_blocks as $inner_block ) {
|
|
@@ -38,9 +38,10 @@ import {
|
|
|
38
38
|
createInterpolateElement,
|
|
39
39
|
} from '@wordpress/element';
|
|
40
40
|
import { placeCaretAtHorizontalEdge } from '@wordpress/dom';
|
|
41
|
-
import { link as linkIcon } from '@wordpress/icons';
|
|
41
|
+
import { link as linkIcon, removeSubmenu } from '@wordpress/icons';
|
|
42
42
|
import { store as coreStore } from '@wordpress/core-data';
|
|
43
43
|
import { speak } from '@wordpress/a11y';
|
|
44
|
+
import { createBlock } from '@wordpress/blocks';
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
47
|
* Internal dependencies
|
|
@@ -294,9 +295,11 @@ export default function NavigationSubmenuEdit( {
|
|
|
294
295
|
};
|
|
295
296
|
const { showSubmenuIcon, openSubmenusOnClick } = context;
|
|
296
297
|
const { saveEntityRecord } = useDispatch( coreStore );
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
|
|
299
|
+
const {
|
|
300
|
+
__unstableMarkNextChangeAsNotPersistent,
|
|
301
|
+
replaceBlock,
|
|
302
|
+
} = useDispatch( blockEditorStore );
|
|
300
303
|
const [ isLinkOpen, setIsLinkOpen ] = useState( false );
|
|
301
304
|
const listItemRef = useRef( null );
|
|
302
305
|
const isDraggingWithin = useIsDraggingWithin( listItemRef );
|
|
@@ -312,6 +315,7 @@ export default function NavigationSubmenuEdit( {
|
|
|
312
315
|
selectedBlockHasDescendants,
|
|
313
316
|
userCanCreatePages,
|
|
314
317
|
userCanCreatePosts,
|
|
318
|
+
onlyDescendantIsEmptyLink,
|
|
315
319
|
} = useSelect(
|
|
316
320
|
( select ) => {
|
|
317
321
|
const {
|
|
@@ -319,13 +323,31 @@ export default function NavigationSubmenuEdit( {
|
|
|
319
323
|
hasSelectedInnerBlock,
|
|
320
324
|
getSelectedBlockClientId,
|
|
321
325
|
getBlockParentsByBlockName,
|
|
326
|
+
getBlock,
|
|
322
327
|
} = select( blockEditorStore );
|
|
323
328
|
|
|
329
|
+
let _onlyDescendantIsEmptyLink;
|
|
330
|
+
|
|
324
331
|
const selectedBlockId = getSelectedBlockClientId();
|
|
325
332
|
|
|
326
333
|
const descendants = getClientIdsOfDescendants( [ clientId ] )
|
|
327
334
|
.length;
|
|
328
335
|
|
|
336
|
+
const selectedBlockDescendants = getClientIdsOfDescendants( [
|
|
337
|
+
selectedBlockId,
|
|
338
|
+
] );
|
|
339
|
+
|
|
340
|
+
// Check for a single descendant in the submenu. If that block
|
|
341
|
+
// is a link block in a "placeholder" state with no label then
|
|
342
|
+
// we can consider as an "empty" link.
|
|
343
|
+
if ( selectedBlockDescendants?.length === 1 ) {
|
|
344
|
+
const singleBlock = getBlock( selectedBlockDescendants[ 0 ] );
|
|
345
|
+
|
|
346
|
+
_onlyDescendantIsEmptyLink =
|
|
347
|
+
singleBlock?.name === 'core/navigation-link' &&
|
|
348
|
+
! singleBlock?.attributes?.label;
|
|
349
|
+
}
|
|
350
|
+
|
|
329
351
|
return {
|
|
330
352
|
isAtMaxNesting:
|
|
331
353
|
getBlockParentsByBlockName( clientId, name ).length >=
|
|
@@ -341,9 +363,7 @@ export default function NavigationSubmenuEdit( {
|
|
|
341
363
|
false
|
|
342
364
|
),
|
|
343
365
|
hasDescendants: !! descendants,
|
|
344
|
-
selectedBlockHasDescendants: !!
|
|
345
|
-
selectedBlockId,
|
|
346
|
-
] )?.length,
|
|
366
|
+
selectedBlockHasDescendants: !! selectedBlockDescendants?.length,
|
|
347
367
|
userCanCreatePages: select( coreStore ).canUser(
|
|
348
368
|
'create',
|
|
349
369
|
'pages'
|
|
@@ -352,6 +372,7 @@ export default function NavigationSubmenuEdit( {
|
|
|
352
372
|
'create',
|
|
353
373
|
'posts'
|
|
354
374
|
),
|
|
375
|
+
onlyDescendantIsEmptyLink: _onlyDescendantIsEmptyLink,
|
|
355
376
|
};
|
|
356
377
|
},
|
|
357
378
|
[ clientId ]
|
|
@@ -529,6 +550,14 @@ export default function NavigationSubmenuEdit( {
|
|
|
529
550
|
|
|
530
551
|
const ParentElement = openSubmenusOnClick ? 'button' : 'a';
|
|
531
552
|
|
|
553
|
+
function transformToLink() {
|
|
554
|
+
const newLinkBlock = createBlock( 'core/navigation-link', attributes );
|
|
555
|
+
replaceBlock( clientId, newLinkBlock );
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
const canConvertToLink =
|
|
559
|
+
! selectedBlockHasDescendants || onlyDescendantIsEmptyLink;
|
|
560
|
+
|
|
532
561
|
return (
|
|
533
562
|
<Fragment>
|
|
534
563
|
<BlockControls>
|
|
@@ -542,6 +571,15 @@ export default function NavigationSubmenuEdit( {
|
|
|
542
571
|
onClick={ () => setIsLinkOpen( true ) }
|
|
543
572
|
/>
|
|
544
573
|
) }
|
|
574
|
+
|
|
575
|
+
<ToolbarButton
|
|
576
|
+
name="revert"
|
|
577
|
+
icon={ removeSubmenu }
|
|
578
|
+
title={ __( 'Convert to Link' ) }
|
|
579
|
+
onClick={ transformToLink }
|
|
580
|
+
className="wp-block-navigation__submenu__revert"
|
|
581
|
+
isDisabled={ ! canConvertToLink }
|
|
582
|
+
/>
|
|
545
583
|
</ToolbarGroup>
|
|
546
584
|
</BlockControls>
|
|
547
585
|
<InspectorControls>
|
|
@@ -657,12 +695,12 @@ export default function NavigationSubmenuEdit( {
|
|
|
657
695
|
/>
|
|
658
696
|
</Popover>
|
|
659
697
|
) }
|
|
660
|
-
{ ( showSubmenuIcon || openSubmenusOnClick ) && (
|
|
661
|
-
<span className="wp-block-navigation__submenu-icon">
|
|
662
|
-
<ItemSubmenuIcon />
|
|
663
|
-
</span>
|
|
664
|
-
) }
|
|
665
698
|
</ParentElement>
|
|
699
|
+
{ ( showSubmenuIcon || openSubmenusOnClick ) && (
|
|
700
|
+
<span className="wp-block-navigation__submenu-icon">
|
|
701
|
+
<ItemSubmenuIcon />
|
|
702
|
+
</span>
|
|
703
|
+
) }
|
|
666
704
|
<div { ...innerBlocksProps } />
|
|
667
705
|
</div>
|
|
668
706
|
</Fragment>
|
|
@@ -167,25 +167,7 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
|
|
|
167
167
|
$label = '';
|
|
168
168
|
|
|
169
169
|
if ( isset( $attributes['label'] ) ) {
|
|
170
|
-
$label .=
|
|
171
|
-
$attributes['label'],
|
|
172
|
-
array(
|
|
173
|
-
'code' => array(),
|
|
174
|
-
'em' => array(),
|
|
175
|
-
'img' => array(
|
|
176
|
-
'scale' => array(),
|
|
177
|
-
'class' => array(),
|
|
178
|
-
'style' => array(),
|
|
179
|
-
'src' => array(),
|
|
180
|
-
'alt' => array(),
|
|
181
|
-
),
|
|
182
|
-
's' => array(),
|
|
183
|
-
'span' => array(
|
|
184
|
-
'style' => array(),
|
|
185
|
-
),
|
|
186
|
-
'strong' => array(),
|
|
187
|
-
)
|
|
188
|
-
);
|
|
170
|
+
$label .= wp_kses_post( $attributes['label'] );
|
|
189
171
|
}
|
|
190
172
|
|
|
191
173
|
$aria_label = sprintf(
|
|
@@ -245,10 +227,10 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
|
|
|
245
227
|
|
|
246
228
|
$html .= '</span>';
|
|
247
229
|
|
|
248
|
-
$html .= '<span class="wp-block-navigation__submenu-icon">' . block_core_navigation_submenu_render_submenu_icon() . '</span>';
|
|
249
|
-
|
|
250
230
|
$html .= '</button>';
|
|
251
231
|
|
|
232
|
+
$html .= '<span class="wp-block-navigation__submenu-icon">' . block_core_navigation_submenu_render_submenu_icon() . '</span>';
|
|
233
|
+
|
|
252
234
|
}
|
|
253
235
|
|
|
254
236
|
if ( $has_submenu ) {
|
package/src/page-list/edit.js
CHANGED
|
@@ -12,12 +12,7 @@ import {
|
|
|
12
12
|
useBlockProps,
|
|
13
13
|
getColorClassName,
|
|
14
14
|
} from '@wordpress/block-editor';
|
|
15
|
-
import {
|
|
16
|
-
ToolbarButton,
|
|
17
|
-
Placeholder,
|
|
18
|
-
Spinner,
|
|
19
|
-
Notice,
|
|
20
|
-
} from '@wordpress/components';
|
|
15
|
+
import { ToolbarButton, Spinner, Notice } from '@wordpress/components';
|
|
21
16
|
import { __ } from '@wordpress/i18n';
|
|
22
17
|
import { useMemo, useState, memo } from '@wordpress/element';
|
|
23
18
|
import { useSelect } from '@wordpress/data';
|
|
@@ -77,9 +72,7 @@ export default function PageListEdit( { context, clientId } ) {
|
|
|
77
72
|
) }
|
|
78
73
|
{ ! hasResolvedPages && (
|
|
79
74
|
<div { ...blockProps }>
|
|
80
|
-
<
|
|
81
|
-
<Spinner />
|
|
82
|
-
</Placeholder>
|
|
75
|
+
<Spinner />
|
|
83
76
|
</div>
|
|
84
77
|
) }
|
|
85
78
|
|
|
@@ -196,7 +189,17 @@ const PageItems = memo( function PageItems( {
|
|
|
196
189
|
} ) }
|
|
197
190
|
>
|
|
198
191
|
{ hasChildren && context.openSubmenusOnClick ? (
|
|
199
|
-
|
|
192
|
+
<>
|
|
193
|
+
<button
|
|
194
|
+
className="wp-block-navigation-item__content wp-block-navigation-submenu__toggle"
|
|
195
|
+
aria-expanded="false"
|
|
196
|
+
>
|
|
197
|
+
{ page.title?.rendered }
|
|
198
|
+
</button>
|
|
199
|
+
<span className="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon">
|
|
200
|
+
<ItemSubmenuIcon />
|
|
201
|
+
</span>
|
|
202
|
+
</>
|
|
200
203
|
) : (
|
|
201
204
|
<a
|
|
202
205
|
className={ classnames(
|
|
@@ -213,7 +216,14 @@ const PageItems = memo( function PageItems( {
|
|
|
213
216
|
{ hasChildren && (
|
|
214
217
|
<>
|
|
215
218
|
{ ! context.openSubmenusOnClick &&
|
|
216
|
-
context.showSubmenuIcon &&
|
|
219
|
+
context.showSubmenuIcon && (
|
|
220
|
+
<button
|
|
221
|
+
className="wp-block-navigation-item__content wp-block-navigation-submenu__toggle wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"
|
|
222
|
+
aria-expanded="false"
|
|
223
|
+
>
|
|
224
|
+
<ItemSubmenuIcon />
|
|
225
|
+
</button>
|
|
226
|
+
) }
|
|
217
227
|
<ul
|
|
218
228
|
className={ classnames( 'submenu-container', {
|
|
219
229
|
'wp-block-navigation__submenu-container': isNavigationChild,
|
|
@@ -232,17 +242,3 @@ const PageItems = memo( function PageItems( {
|
|
|
232
242
|
);
|
|
233
243
|
} );
|
|
234
244
|
} );
|
|
235
|
-
|
|
236
|
-
function ItemSubmenuToggle( { title } ) {
|
|
237
|
-
return (
|
|
238
|
-
<button
|
|
239
|
-
className="wp-block-navigation-item__content wp-block-navigation-submenu__toggle"
|
|
240
|
-
aria-expanded="false"
|
|
241
|
-
>
|
|
242
|
-
{ title }
|
|
243
|
-
<span className="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon">
|
|
244
|
-
<ItemSubmenuIcon />
|
|
245
|
-
</span>
|
|
246
|
-
</button>
|
|
247
|
-
);
|
|
248
|
-
}
|
|
@@ -27,16 +27,6 @@
|
|
|
27
27
|
pointer-events: none;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
.wp-block-page-list .components-placeholder {
|
|
31
|
-
min-height: 0;
|
|
32
|
-
padding: 0;
|
|
33
|
-
background-color: inherit;
|
|
34
|
-
|
|
35
|
-
.components-spinner {
|
|
36
|
-
margin: 0.5em;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
30
|
// Modal that shows conversion option.
|
|
41
31
|
.wp-block-page-list-modal {
|
|
42
32
|
@include break-small() {
|