@wordpress/block-library 6.0.7 → 6.0.11
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/cover/edit.js +8 -3
- package/build/cover/edit.js.map +1 -1
- package/build/cover/transforms.js +2 -0
- package/build/cover/transforms.js.map +1 -1
- package/build/gallery/edit.js +1 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/v1/update-gallery-modal.js +1 -1
- package/build/gallery/v1/update-gallery-modal.js.map +1 -1
- package/build/index.js +4 -3
- package/build/index.js.map +1 -1
- package/build/navigation/deprecated.js +127 -19
- package/build/navigation/deprecated.js.map +1 -1
- package/build/navigation/edit/index.js +59 -33
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +1 -1
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +2 -2
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +16 -48
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +5 -2
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +4 -35
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js +50 -0
- package/build/navigation/edit/use-create-navigation-menu.js.map +1 -0
- package/build/navigation/edit/use-generate-default-navigation-title.js +73 -0
- package/build/navigation/edit/use-generate-default-navigation-title.js.map +1 -0
- package/build/navigation/index.js +1 -1
- package/build/navigation/save.js +2 -2
- package/build/navigation/save.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +19 -8
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation-area/edit.js +5 -0
- package/build/navigation-area/edit.js.map +1 -1
- package/build/page-list/edit.js +40 -42
- package/build/page-list/edit.js.map +1 -1
- package/build/pattern/index.js +1 -1
- package/build/post-featured-image/edit.js +53 -23
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-terms/index.js +1 -1
- package/build/post-title/edit.js +2 -2
- package/build/post-title/edit.js.map +1 -1
- package/build/query-pagination-next/index.js +1 -1
- package/build/query-pagination-previous/index.js +1 -1
- package/build/query-title/index.js +1 -1
- package/build/site-logo/index.js +1 -1
- package/build/site-tagline/index.js +1 -1
- package/build/site-title/index.js +1 -1
- package/build/template-part/edit/placeholder/index.js +1 -1
- package/build/template-part/edit/placeholder/index.js.map +1 -1
- package/build/template-part/index.js +2 -1
- package/build/template-part/index.js.map +1 -1
- package/build-module/cover/edit.js +8 -3
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/cover/transforms.js +2 -0
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/gallery/edit.js +1 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/v1/update-gallery-modal.js +1 -1
- package/build-module/gallery/v1/update-gallery-modal.js.map +1 -1
- package/build-module/index.js +4 -3
- package/build-module/index.js.map +1 -1
- package/build-module/navigation/deprecated.js +127 -19
- package/build-module/navigation/deprecated.js.map +1 -1
- package/build-module/navigation/edit/index.js +60 -33
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +1 -1
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +2 -2
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +15 -45
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +5 -2
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +6 -35
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js +36 -0
- package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -0
- package/build-module/navigation/edit/use-generate-default-navigation-title.js +57 -0
- package/build-module/navigation/edit/use-generate-default-navigation-title.js.map +1 -0
- package/build-module/navigation/index.js +1 -1
- package/build-module/navigation/save.js +2 -2
- package/build-module/navigation/save.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +19 -8
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation-area/edit.js +4 -0
- package/build-module/navigation-area/edit.js.map +1 -1
- package/build-module/page-list/edit.js +41 -43
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/pattern/index.js +1 -1
- package/build-module/post-featured-image/edit.js +55 -26
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-terms/index.js +1 -1
- package/build-module/post-title/edit.js +2 -2
- package/build-module/post-title/edit.js.map +1 -1
- package/build-module/query-pagination-next/index.js +1 -1
- package/build-module/query-pagination-previous/index.js +1 -1
- package/build-module/query-title/index.js +1 -1
- package/build-module/site-logo/index.js +1 -1
- package/build-module/site-tagline/index.js +1 -1
- package/build-module/site-title/index.js +1 -1
- package/build-module/template-part/edit/placeholder/index.js +2 -2
- package/build-module/template-part/edit/placeholder/index.js.map +1 -1
- package/build-module/template-part/index.js +2 -1
- package/build-module/template-part/index.js.map +1 -1
- package/build-style/code/theme-rtl.css +1 -1
- package/build-style/code/theme.css +1 -1
- package/build-style/cover/style-rtl.css +8 -2
- package/build-style/cover/style.css +8 -2
- package/build-style/editor-rtl.css +104 -53
- package/build-style/editor.css +104 -53
- package/build-style/gallery/editor-rtl.css +1 -0
- package/build-style/gallery/editor.css +1 -0
- package/build-style/navigation/style-rtl.css +41 -3
- package/build-style/navigation/style.css +41 -3
- package/build-style/post-comments-form/style-rtl.css +18 -0
- package/build-style/post-comments-form/style.css +18 -0
- package/build-style/post-featured-image/editor-rtl.css +100 -16
- package/build-style/post-featured-image/editor.css +100 -16
- package/build-style/site-logo/editor-rtl.css +2 -2
- package/build-style/site-logo/editor.css +2 -2
- package/build-style/social-links/editor-rtl.css +1 -35
- package/build-style/social-links/editor.css +1 -35
- package/build-style/style-rtl.css +67 -27
- package/build-style/style.css +67 -27
- package/build-style/theme-rtl.css +1 -1
- package/build-style/theme.css +1 -1
- package/package.json +8 -8
- package/src/calendar/index.php +3 -3
- package/src/code/theme.scss +1 -1
- package/src/cover/edit.js +8 -1
- package/src/cover/style.scss +9 -2
- package/src/cover/transforms.js +2 -0
- package/src/gallery/edit.js +1 -1
- package/src/gallery/editor.scss +1 -0
- package/src/gallery/index.php +1 -1
- package/src/gallery/v1/update-gallery-modal.js +1 -1
- package/src/home-link/index.php +1 -1
- package/src/image/index.php +1 -1
- package/src/index.js +28 -26
- package/src/navigation/block.json +1 -1
- package/src/navigation/deprecated.js +115 -13
- package/src/navigation/edit/index.js +68 -36
- package/src/navigation/edit/inner-blocks.js +2 -1
- package/src/navigation/edit/navigation-menu-selector.js +2 -2
- package/src/navigation/edit/placeholder/index.js +16 -62
- package/src/navigation/edit/responsive-wrapper.js +8 -1
- package/src/navigation/edit/unsaved-inner-blocks.js +6 -57
- package/src/navigation/edit/use-create-navigation-menu.js +39 -0
- package/src/navigation/edit/use-generate-default-navigation-title.js +79 -0
- package/src/navigation/index.php +171 -25
- package/src/navigation/save.js +2 -2
- package/src/navigation/style.scss +57 -5
- package/src/navigation/use-navigation-menu.js +20 -9
- package/src/navigation-area/edit.js +5 -0
- package/src/navigation-area/index.php +2 -1
- package/src/navigation-link/index.php +1 -1
- package/src/navigation-submenu/index.php +2 -8
- package/src/page-list/edit.js +35 -44
- package/src/page-list/index.php +10 -5
- package/src/pattern/block.json +1 -1
- package/src/post-comments-form/style.scss +20 -1
- package/src/post-featured-image/edit.js +58 -26
- package/src/post-featured-image/editor.scss +124 -20
- package/src/post-terms/block.json +1 -1
- package/src/post-title/edit.js +2 -2
- package/src/query-pagination-next/block.json +1 -1
- package/src/query-pagination-previous/block.json +1 -1
- package/src/query-title/block.json +1 -1
- package/src/site-logo/block.json +1 -1
- package/src/site-logo/editor.scss +3 -2
- package/src/site-tagline/block.json +1 -1
- package/src/site-title/block.json +1 -1
- package/src/social-links/editor.scss +1 -47
- package/src/style.scss +0 -1
- package/src/table-of-contents/index.php +1 -1
- package/src/template-part/block.json +2 -1
- package/src/template-part/edit/placeholder/index.js +2 -2
- package/src/template-part/index.php +2 -1
- package/build/navigation/edit/navigation-menu-name-modal.js +0 -55
- package/build/navigation/edit/navigation-menu-name-modal.js.map +0 -1
- package/build/navigation/edit/navigation-menu-publish-button.js +0 -53
- package/build/navigation/edit/navigation-menu-publish-button.js.map +0 -1
- package/build-module/navigation/edit/navigation-menu-name-modal.js +0 -47
- package/build-module/navigation/edit/navigation-menu-name-modal.js.map +0 -1
- package/build-module/navigation/edit/navigation-menu-publish-button.js +0 -40
- package/build-module/navigation/edit/navigation-menu-publish-button.js.map +0 -1
- package/build-style/navigation-submenu/style-rtl.css +0 -97
- package/build-style/navigation-submenu/style.css +0 -97
- package/src/navigation/edit/navigation-menu-name-modal.js +0 -69
- package/src/navigation/edit/navigation-menu-publish-button.js +0 -57
- package/src/navigation-submenu/style.scss +0 -25
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
import { store as coreStore } from '@wordpress/core-data';
|
|
5
5
|
import { useSelect } from '@wordpress/data';
|
|
6
6
|
|
|
7
|
-
export default function useNavigationMenu(
|
|
7
|
+
export default function useNavigationMenu( ref ) {
|
|
8
8
|
return useSelect(
|
|
9
9
|
( select ) => {
|
|
10
10
|
const {
|
|
11
|
+
getEntityRecord,
|
|
11
12
|
getEditedEntityRecord,
|
|
12
13
|
getEntityRecords,
|
|
13
14
|
hasFinishedResolution,
|
|
@@ -16,12 +17,22 @@ export default function useNavigationMenu( navigationMenuId ) {
|
|
|
16
17
|
const navigationMenuSingleArgs = [
|
|
17
18
|
'postType',
|
|
18
19
|
'wp_navigation',
|
|
19
|
-
|
|
20
|
+
ref,
|
|
20
21
|
];
|
|
21
|
-
const
|
|
22
|
+
const rawNavigationMenu = ref
|
|
23
|
+
? getEntityRecord( ...navigationMenuSingleArgs )
|
|
24
|
+
: null;
|
|
25
|
+
let navigationMenu = ref
|
|
22
26
|
? getEditedEntityRecord( ...navigationMenuSingleArgs )
|
|
23
27
|
: null;
|
|
24
|
-
|
|
28
|
+
|
|
29
|
+
// getEditedEntityRecord will return the post regardless of status.
|
|
30
|
+
// Therefore if the found post is not published then we should ignore it.
|
|
31
|
+
if ( navigationMenu?.status !== 'publish' ) {
|
|
32
|
+
navigationMenu = null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const hasResolvedNavigationMenu = ref
|
|
25
36
|
? hasFinishedResolution(
|
|
26
37
|
'getEditedEntityRecord',
|
|
27
38
|
navigationMenuSingleArgs
|
|
@@ -31,21 +42,21 @@ export default function useNavigationMenu( navigationMenuId ) {
|
|
|
31
42
|
const navigationMenuMultipleArgs = [
|
|
32
43
|
'postType',
|
|
33
44
|
'wp_navigation',
|
|
34
|
-
{ per_page: -1 },
|
|
45
|
+
{ per_page: -1, status: 'publish' },
|
|
35
46
|
];
|
|
36
47
|
const navigationMenus = getEntityRecords(
|
|
37
48
|
...navigationMenuMultipleArgs
|
|
38
49
|
);
|
|
39
50
|
|
|
40
|
-
const canSwitchNavigationMenu =
|
|
51
|
+
const canSwitchNavigationMenu = ref
|
|
41
52
|
? navigationMenus?.length > 1
|
|
42
53
|
: navigationMenus?.length > 0;
|
|
43
54
|
|
|
44
55
|
return {
|
|
45
56
|
isNavigationMenuResolved: hasResolvedNavigationMenu,
|
|
46
57
|
isNavigationMenuMissing:
|
|
47
|
-
!
|
|
48
|
-
( hasResolvedNavigationMenu && !
|
|
58
|
+
! ref ||
|
|
59
|
+
( hasResolvedNavigationMenu && ! rawNavigationMenu ),
|
|
49
60
|
canSwitchNavigationMenu,
|
|
50
61
|
hasResolvedNavigationMenus: hasFinishedResolution(
|
|
51
62
|
'getEntityRecords',
|
|
@@ -55,6 +66,6 @@ export default function useNavigationMenu( navigationMenuId ) {
|
|
|
55
66
|
navigationMenus,
|
|
56
67
|
};
|
|
57
68
|
},
|
|
58
|
-
[
|
|
69
|
+
[ ref ]
|
|
59
70
|
);
|
|
60
71
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __, _x } from '@wordpress/i18n';
|
|
5
|
+
import deprecated from '@wordpress/deprecated';
|
|
5
6
|
import { store as coreStore } from '@wordpress/core-data';
|
|
6
7
|
import {
|
|
7
8
|
MenuGroup,
|
|
@@ -51,6 +52,10 @@ function NavigationAreaBlock( { attributes, setAttributes } ) {
|
|
|
51
52
|
[ navigationAreas ]
|
|
52
53
|
);
|
|
53
54
|
|
|
55
|
+
deprecated( 'wp.blockLibrary.NavigationArea', {
|
|
56
|
+
since: '5.9',
|
|
57
|
+
} );
|
|
58
|
+
|
|
54
59
|
return (
|
|
55
60
|
<>
|
|
56
61
|
<BlockControls>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Server-side rendering of the `core/navigation-submenu` block.
|
|
4
4
|
*
|
|
5
|
-
* @package
|
|
5
|
+
* @package WordPress
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -19,7 +19,7 @@ function block_core_navigation_submenu_build_css_colors( $context, $attributes )
|
|
|
19
19
|
'inline_styles' => '',
|
|
20
20
|
);
|
|
21
21
|
|
|
22
|
-
$is_sub_menu = isset( $attributes['
|
|
22
|
+
$is_sub_menu = isset( $attributes['isTopLevelItem'] ) ? ( ! $attributes['isTopLevelItem'] ) : false;
|
|
23
23
|
|
|
24
24
|
// Text color.
|
|
25
25
|
$named_text_color = null;
|
|
@@ -150,12 +150,6 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
|
|
|
150
150
|
$has_submenu = count( $block->inner_blocks ) > 0;
|
|
151
151
|
$is_active = ! empty( $attributes['id'] ) && ( get_the_ID() === $attributes['id'] );
|
|
152
152
|
|
|
153
|
-
$class_name = ! empty( $attributes['className'] ) ? implode( ' ', (array) $attributes['className'] ) : false;
|
|
154
|
-
|
|
155
|
-
if ( false !== $class_name ) {
|
|
156
|
-
$css_classes .= ' ' . $class_name;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
153
|
$show_submenu_indicators = isset( $block->context['showSubmenuIcon'] ) && $block->context['showSubmenuIcon'];
|
|
160
154
|
$open_on_click = isset( $block->context['openSubmenusOnClick'] ) && $block->context['openSubmenusOnClick'];
|
|
161
155
|
$open_on_hover_and_click = isset( $block->context['openSubmenusOnClick'] ) && ! $block->context['openSubmenusOnClick'] &&
|
package/src/page-list/edit.js
CHANGED
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
} from '@wordpress/block-editor';
|
|
15
15
|
import { ToolbarButton, Placeholder, Spinner } from '@wordpress/components';
|
|
16
16
|
import { __ } from '@wordpress/i18n';
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
17
|
+
import { useMemo, useState, memo } from '@wordpress/element';
|
|
18
|
+
import { useSelect } from '@wordpress/data';
|
|
19
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Internal dependencies
|
|
@@ -70,7 +70,7 @@ export default function PageListEdit( { context, clientId } ) {
|
|
|
70
70
|
clientId={ clientId }
|
|
71
71
|
/>
|
|
72
72
|
) }
|
|
73
|
-
{ totalPages ===
|
|
73
|
+
{ totalPages === undefined && (
|
|
74
74
|
<div { ...blockProps }>
|
|
75
75
|
<Placeholder>
|
|
76
76
|
<Spinner />
|
|
@@ -95,48 +95,39 @@ export default function PageListEdit( { context, clientId } ) {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
function usePagesByParentId() {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
order: 'asc',
|
|
110
|
-
_fields: [ 'id', 'link', 'parent', 'title', 'menu_order' ],
|
|
111
|
-
per_page: -1,
|
|
112
|
-
} ),
|
|
113
|
-
} );
|
|
114
|
-
|
|
115
|
-
// TODO: Once the REST API supports passing multiple values to
|
|
116
|
-
// 'orderby', this can be removed.
|
|
117
|
-
// https://core.trac.wordpress.org/ticket/39037
|
|
118
|
-
pages = sortBy( pages, [ 'menu_order', 'title.rendered' ] );
|
|
119
|
-
|
|
120
|
-
setPagesByParentId(
|
|
121
|
-
pages.reduce( ( accumulator, page ) => {
|
|
122
|
-
const { parent } = page;
|
|
123
|
-
if ( accumulator.has( parent ) ) {
|
|
124
|
-
accumulator.get( parent ).push( page );
|
|
125
|
-
} else {
|
|
126
|
-
accumulator.set( parent, [ page ] );
|
|
127
|
-
}
|
|
128
|
-
return accumulator;
|
|
129
|
-
}, new Map() )
|
|
130
|
-
);
|
|
131
|
-
setTotalPages( pages.length );
|
|
132
|
-
}
|
|
133
|
-
performFetch();
|
|
98
|
+
const { pages } = useSelect( ( select ) => {
|
|
99
|
+
const { getEntityRecords } = select( coreStore );
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
pages: getEntityRecords( 'postType', 'page', {
|
|
103
|
+
orderby: 'menu_order',
|
|
104
|
+
order: 'asc',
|
|
105
|
+
_fields: [ 'id', 'link', 'parent', 'title', 'menu_order' ],
|
|
106
|
+
per_page: -1,
|
|
107
|
+
} ),
|
|
108
|
+
};
|
|
134
109
|
}, [] );
|
|
135
110
|
|
|
136
|
-
return {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
111
|
+
return useMemo( () => {
|
|
112
|
+
// TODO: Once the REST API supports passing multiple values to
|
|
113
|
+
// 'orderby', this can be removed.
|
|
114
|
+
// https://core.trac.wordpress.org/ticket/39037
|
|
115
|
+
const sortedPages = sortBy( pages, [ 'menu_order', 'title.rendered' ] );
|
|
116
|
+
const pagesByParentId = sortedPages.reduce( ( accumulator, page ) => {
|
|
117
|
+
const { parent } = page;
|
|
118
|
+
if ( accumulator.has( parent ) ) {
|
|
119
|
+
accumulator.get( parent ).push( page );
|
|
120
|
+
} else {
|
|
121
|
+
accumulator.set( parent, [ page ] );
|
|
122
|
+
}
|
|
123
|
+
return accumulator;
|
|
124
|
+
}, new Map() );
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
pagesByParentId,
|
|
128
|
+
totalPages: pages?.length,
|
|
129
|
+
};
|
|
130
|
+
}, [ pages ] );
|
|
140
131
|
}
|
|
141
132
|
|
|
142
133
|
const PageItems = memo( function PageItems( {
|
package/src/page-list/index.php
CHANGED
|
@@ -34,7 +34,7 @@ function block_core_page_list_build_css_colors( $attributes, $context ) {
|
|
|
34
34
|
|
|
35
35
|
if ( $has_named_text_color ) {
|
|
36
36
|
// Add the color class.
|
|
37
|
-
$colors['css_classes'][] = sprintf( 'has-%s-color',
|
|
37
|
+
$colors['css_classes'][] = sprintf( 'has-%s-color', _wp_to_kebab_case( $context['textColor'] ) );
|
|
38
38
|
} elseif ( $has_picked_text_color ) {
|
|
39
39
|
$colors['inline_styles'] .= sprintf( 'color: %s;', $context['customTextColor'] );
|
|
40
40
|
} elseif ( $has_custom_text_color ) {
|
|
@@ -55,7 +55,7 @@ function block_core_page_list_build_css_colors( $attributes, $context ) {
|
|
|
55
55
|
|
|
56
56
|
if ( $has_named_background_color ) {
|
|
57
57
|
// Add the background-color class.
|
|
58
|
-
$colors['css_classes'][] = sprintf( 'has-%s-background-color',
|
|
58
|
+
$colors['css_classes'][] = sprintf( 'has-%s-background-color', _wp_to_kebab_case( $context['backgroundColor'] ) );
|
|
59
59
|
} elseif ( $has_picked_background_color ) {
|
|
60
60
|
$colors['inline_styles'] .= sprintf( 'background-color: %s;', $context['customBackgroundColor'] );
|
|
61
61
|
} elseif ( $has_custom_background_color ) {
|
|
@@ -74,7 +74,7 @@ function block_core_page_list_build_css_colors( $attributes, $context ) {
|
|
|
74
74
|
|
|
75
75
|
// Give overlay colors priority, fall back to Navigation block colors, then global styles.
|
|
76
76
|
if ( $has_named_overlay_text_color ) {
|
|
77
|
-
$colors['overlay_css_classes'][] = sprintf( 'has-%s-color',
|
|
77
|
+
$colors['overlay_css_classes'][] = sprintf( 'has-%s-color', _wp_to_kebab_case( $context['overlayTextColor'] ) );
|
|
78
78
|
} elseif ( $has_picked_overlay_text_color ) {
|
|
79
79
|
$colors['overlay_inline_styles'] .= sprintf( 'color: %s;', $context['customOverlayTextColor'] );
|
|
80
80
|
}
|
|
@@ -89,7 +89,7 @@ function block_core_page_list_build_css_colors( $attributes, $context ) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
if ( $has_named_overlay_background_color ) {
|
|
92
|
-
$colors['overlay_css_classes'][] = sprintf( 'has-%s-background-color',
|
|
92
|
+
$colors['overlay_css_classes'][] = sprintf( 'has-%s-background-color', _wp_to_kebab_case( $context['overlayBackgroundColor'] ) );
|
|
93
93
|
} elseif ( $has_picked_overlay_background_color ) {
|
|
94
94
|
$colors['overlay_inline_styles'] .= sprintf( 'background-color: %s;', $context['customOverlayBackgroundColor'] );
|
|
95
95
|
}
|
|
@@ -182,7 +182,7 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click,
|
|
|
182
182
|
) . '<span class="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" role="img" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg></span>' .
|
|
183
183
|
'</button>';
|
|
184
184
|
} else {
|
|
185
|
-
$markup .= '<a class="wp-block-pages-list__item__link' . $navigation_child_content_class . '
|
|
185
|
+
$markup .= '<a class="wp-block-pages-list__item__link' . $navigation_child_content_class . '" href="' . esc_url( $page['link'] ) . '"' . $aria_current . '>' . wp_kses(
|
|
186
186
|
$page['title'],
|
|
187
187
|
wp_kses_allowed_html( 'post' )
|
|
188
188
|
) . '</a>';
|
|
@@ -293,6 +293,11 @@ function render_block_core_page_list( $attributes, $content, $block ) {
|
|
|
293
293
|
|
|
294
294
|
$nested_pages = block_core_page_list_nest_pages( $top_level_pages, $pages_with_children );
|
|
295
295
|
|
|
296
|
+
// Limit the number of items to be visually displayed.
|
|
297
|
+
if ( ! empty( $attributes['__unstableMaxPages'] ) ) {
|
|
298
|
+
$nested_pages = array_slice( $nested_pages, 0, $attributes['__unstableMaxPages'] );
|
|
299
|
+
}
|
|
300
|
+
|
|
296
301
|
$is_navigation_child = array_key_exists( 'showSubmenuIcon', $block->context );
|
|
297
302
|
|
|
298
303
|
$open_submenus_on_click = array_key_exists( 'openSubmenusOnClick', $block->context ) ? $block->context['openSubmenusOnClick'] : false;
|
package/src/pattern/block.json
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
|
-
// Styles copied from button block styles.
|
|
2
1
|
.wp-block-post-comments-form {
|
|
2
|
+
&[style*="font-weight"] :where(.comment-reply-title) {
|
|
3
|
+
font-weight: inherit;
|
|
4
|
+
}
|
|
5
|
+
&[style*="font-family"] :where(.comment-reply-title) {
|
|
6
|
+
font-family: inherit;
|
|
7
|
+
}
|
|
8
|
+
&[class*="-font-size"] :where(.comment-reply-title),
|
|
9
|
+
&[style*="font-size"] :where(.comment-reply-title) {
|
|
10
|
+
font-size: inherit;
|
|
11
|
+
}
|
|
12
|
+
&[style*="line-height"] :where(.comment-reply-title) {
|
|
13
|
+
line-height: inherit;
|
|
14
|
+
}
|
|
15
|
+
&[style*="font-style"] :where(.comment-reply-title) {
|
|
16
|
+
font-style: inherit;
|
|
17
|
+
}
|
|
18
|
+
&[style*="letter-spacing"] :where(.comment-reply-title) {
|
|
19
|
+
letter-spacing: inherit;
|
|
20
|
+
}
|
|
3
21
|
|
|
22
|
+
// Styles copied from button block styles.
|
|
4
23
|
input[type="submit"] {
|
|
5
24
|
border: none;
|
|
6
25
|
box-shadow: none;
|
|
@@ -2,34 +2,46 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useEntityProp, store as coreStore } from '@wordpress/core-data';
|
|
5
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
6
|
import {
|
|
7
|
-
Icon,
|
|
8
7
|
ToggleControl,
|
|
9
8
|
PanelBody,
|
|
10
|
-
|
|
9
|
+
Placeholder,
|
|
10
|
+
Button,
|
|
11
11
|
} from '@wordpress/components';
|
|
12
12
|
import {
|
|
13
13
|
InspectorControls,
|
|
14
14
|
BlockControls,
|
|
15
15
|
MediaPlaceholder,
|
|
16
16
|
MediaReplaceFlow,
|
|
17
|
-
BlockIcon,
|
|
18
17
|
useBlockProps,
|
|
19
18
|
} from '@wordpress/block-editor';
|
|
20
19
|
import { __, sprintf } from '@wordpress/i18n';
|
|
21
|
-
import {
|
|
20
|
+
import { upload } from '@wordpress/icons';
|
|
21
|
+
import { SVG, Path } from '@wordpress/primitives';
|
|
22
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Internal dependencies
|
|
25
26
|
*/
|
|
26
27
|
import DimensionControls from './dimension-controls';
|
|
27
28
|
|
|
29
|
+
const placeholderIllustration = (
|
|
30
|
+
<SVG
|
|
31
|
+
className="components-placeholder__illustration"
|
|
32
|
+
fill="none"
|
|
33
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
34
|
+
viewBox="0 0 60 60"
|
|
35
|
+
preserveAspectRatio="none"
|
|
36
|
+
>
|
|
37
|
+
<Path vectorEffect="non-scaling-stroke" d="M60 60 0 0" />
|
|
38
|
+
</SVG>
|
|
39
|
+
);
|
|
40
|
+
|
|
28
41
|
const ALLOWED_MEDIA_TYPES = [ 'image' ];
|
|
29
42
|
const placeholderChip = (
|
|
30
|
-
<div className="post-featured-
|
|
31
|
-
|
|
32
|
-
<p> { __( 'Featured Image' ) }</p>
|
|
43
|
+
<div className="wp-block-post-featured-image__placeholder">
|
|
44
|
+
{ placeholderIllustration }
|
|
33
45
|
</div>
|
|
34
46
|
);
|
|
35
47
|
|
|
@@ -37,8 +49,6 @@ function PostFeaturedImageDisplay( {
|
|
|
37
49
|
attributes,
|
|
38
50
|
setAttributes,
|
|
39
51
|
context: { postId, postType, queryId },
|
|
40
|
-
noticeUI,
|
|
41
|
-
noticeOperations,
|
|
42
52
|
} ) {
|
|
43
53
|
const isDescendentOfQueryLoop = !! queryId;
|
|
44
54
|
const { isLink, height, width, scale } = attributes;
|
|
@@ -48,42 +58,66 @@ function PostFeaturedImageDisplay( {
|
|
|
48
58
|
'featured_media',
|
|
49
59
|
postId
|
|
50
60
|
);
|
|
61
|
+
|
|
51
62
|
const media = useSelect(
|
|
52
63
|
( select ) =>
|
|
53
64
|
featuredImage &&
|
|
54
65
|
select( coreStore ).getMedia( featuredImage, { context: 'view' } ),
|
|
55
66
|
[ featuredImage ]
|
|
56
67
|
);
|
|
68
|
+
|
|
57
69
|
const blockProps = useBlockProps( {
|
|
58
|
-
style: { width },
|
|
70
|
+
style: { width, height },
|
|
59
71
|
} );
|
|
72
|
+
|
|
73
|
+
const placeholder = ( content ) => {
|
|
74
|
+
return (
|
|
75
|
+
<Placeholder className="block-editor-media-placeholder">
|
|
76
|
+
{ placeholderIllustration }
|
|
77
|
+
{ content }
|
|
78
|
+
</Placeholder>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
60
82
|
const onSelectImage = ( value ) => {
|
|
61
83
|
if ( value?.id ) {
|
|
62
84
|
setFeaturedImage( value.id );
|
|
63
85
|
}
|
|
64
86
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
87
|
+
|
|
88
|
+
const { createErrorNotice } = useDispatch( noticesStore );
|
|
89
|
+
const onUploadError = ( message ) => {
|
|
90
|
+
createErrorNotice( message[ 2 ], { type: 'snackbar' } );
|
|
91
|
+
};
|
|
92
|
+
|
|
69
93
|
let image;
|
|
70
94
|
if ( ! featuredImage && isDescendentOfQueryLoop ) {
|
|
71
95
|
return <div { ...blockProps }>{ placeholderChip }</div>;
|
|
72
96
|
}
|
|
97
|
+
|
|
98
|
+
const label = __( 'Add a featured image' );
|
|
99
|
+
|
|
73
100
|
if ( ! featuredImage ) {
|
|
74
101
|
image = (
|
|
75
102
|
<MediaPlaceholder
|
|
76
|
-
icon={ <BlockIcon icon={ postFeaturedImage } /> }
|
|
77
103
|
onSelect={ onSelectImage }
|
|
78
|
-
notices={ noticeUI }
|
|
79
|
-
onError={ onUploadError }
|
|
80
104
|
accept="image/*"
|
|
81
105
|
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
106
|
+
onError={ onUploadError }
|
|
107
|
+
placeholder={ placeholder }
|
|
108
|
+
mediaLibraryButton={ ( { open } ) => {
|
|
109
|
+
return (
|
|
110
|
+
<Button
|
|
111
|
+
icon={ upload }
|
|
112
|
+
variant="primary"
|
|
113
|
+
label={ label }
|
|
114
|
+
showTooltip
|
|
115
|
+
tooltipPosition="top center"
|
|
116
|
+
onClick={ () => {
|
|
117
|
+
open();
|
|
118
|
+
} }
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
87
121
|
} }
|
|
88
122
|
/>
|
|
89
123
|
);
|
|
@@ -136,12 +170,10 @@ function PostFeaturedImageDisplay( {
|
|
|
136
170
|
);
|
|
137
171
|
}
|
|
138
172
|
|
|
139
|
-
const PostFeaturedImageWithNotices = withNotices( PostFeaturedImageDisplay );
|
|
140
|
-
|
|
141
173
|
export default function PostFeaturedImageEdit( props ) {
|
|
142
174
|
const blockProps = useBlockProps();
|
|
143
175
|
if ( ! props.context?.postId ) {
|
|
144
176
|
return <div { ...blockProps }>{ placeholderChip }</div>;
|
|
145
177
|
}
|
|
146
|
-
return <
|
|
178
|
+
return <PostFeaturedImageDisplay { ...props } />;
|
|
147
179
|
}
|
|
@@ -1,33 +1,137 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// Give the featured image placeholder the appearance of a literal image placeholder.
|
|
2
|
+
// @todo: this CSS is similar to that of the Site Logo. That makes it an opportunity
|
|
3
|
+
// to create a new component for placeholders meant to inherit some theme styles.
|
|
4
|
+
.wp-block-post-featured-image.wp-block-post-featured-image {
|
|
5
|
+
// Inherit border radius from style variations.
|
|
6
|
+
.components-placeholder,
|
|
7
|
+
.components-resizable-box__container {
|
|
8
|
+
border-radius: inherit;
|
|
6
9
|
}
|
|
7
|
-
}
|
|
8
10
|
|
|
9
|
-
.
|
|
10
|
-
.post-featured-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
// Style the placeholder.
|
|
12
|
+
.wp-block-post-featured-image__placeholder,
|
|
13
|
+
.components-placeholder {
|
|
14
|
+
justify-content: center;
|
|
13
15
|
align-items: center;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
box-shadow: none;
|
|
17
|
+
padding: 0;
|
|
18
|
+
|
|
19
|
+
// Hide the upload button, as it's also available in the media library.
|
|
20
|
+
.components-form-file-upload {
|
|
21
|
+
display: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Position the spinner.
|
|
25
|
+
.components-placeholder__preview {
|
|
26
|
+
position: absolute;
|
|
27
|
+
top: $grid-unit-05;
|
|
28
|
+
right: $grid-unit-05;
|
|
29
|
+
bottom: $grid-unit-05;
|
|
30
|
+
left: $grid-unit-05;
|
|
31
|
+
background: rgba($white, 0.8);
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Draw the dashed outline.
|
|
38
|
+
// By setting the dashed border to currentColor, we ensure it's visible
|
|
39
|
+
// against any background color.
|
|
40
|
+
color: currentColor;
|
|
41
|
+
background: transparent;
|
|
42
|
+
&::before {
|
|
43
|
+
content: "";
|
|
44
|
+
display: block;
|
|
45
|
+
position: absolute;
|
|
46
|
+
top: 0;
|
|
47
|
+
right: 0;
|
|
48
|
+
bottom: 0;
|
|
49
|
+
left: 0;
|
|
50
|
+
border: $border-width dashed currentColor;
|
|
51
|
+
opacity: 0.4;
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
|
|
54
|
+
// Inherit border radius from style variations.
|
|
55
|
+
border-radius: inherit;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Style the upload button.
|
|
59
|
+
.components-placeholder__fieldset {
|
|
60
|
+
width: auto;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.components-button.components-button {
|
|
64
|
+
color: inherit;
|
|
65
|
+
padding: 0;
|
|
66
|
+
display: flex;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
align-items: center;
|
|
69
|
+
width: $grid-unit-60;
|
|
70
|
+
height: $grid-unit-60;
|
|
71
|
+
border-radius: 50%;
|
|
72
|
+
position: relative;
|
|
73
|
+
visibility: hidden;
|
|
74
|
+
|
|
75
|
+
// Animation.
|
|
76
|
+
background: transparent;
|
|
77
|
+
transition: all 0.1s linear;
|
|
78
|
+
@include reduce-motion("transition");
|
|
20
79
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
80
|
+
|
|
81
|
+
.components-button.components-button > svg {
|
|
82
|
+
color: $white;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Style the placeholder illustration.
|
|
86
|
+
.components-placeholder__illustration {
|
|
87
|
+
position: absolute;
|
|
88
|
+
top: 0;
|
|
89
|
+
right: 0;
|
|
90
|
+
bottom: 0;
|
|
91
|
+
left: 0;
|
|
92
|
+
width: 100%;
|
|
93
|
+
height: 100%;
|
|
94
|
+
stroke: currentColor;
|
|
95
|
+
stroke-dasharray: 3;
|
|
96
|
+
opacity: 0.4;
|
|
25
97
|
}
|
|
98
|
+
|
|
99
|
+
// Show default placeholder height when not resized.
|
|
100
|
+
min-height: 200px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Provide a minimum size for the placeholder when resized.
|
|
104
|
+
// Note, this should be as small as we can afford it, and exists only
|
|
105
|
+
// to ensure there's room for the upload button.
|
|
106
|
+
&[style*="height"] .components-placeholder {
|
|
107
|
+
min-height: $grid-unit-60;
|
|
108
|
+
min-width: $grid-unit-60;
|
|
109
|
+
height: 100%;
|
|
110
|
+
width: 100%;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Show upload button on block selection.
|
|
114
|
+
&.is-selected .components-button.components-button {
|
|
115
|
+
background: var(--wp-admin-theme-color);
|
|
116
|
+
border-color: var(--wp-admin-theme-color);
|
|
117
|
+
border-style: solid;
|
|
118
|
+
color: $white;
|
|
119
|
+
opacity: 1;
|
|
120
|
+
visibility: visible;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
div[data-type="core/post-featured-image"] {
|
|
125
|
+
img {
|
|
126
|
+
max-width: 100%;
|
|
127
|
+
height: auto;
|
|
128
|
+
display: block;
|
|
26
129
|
}
|
|
27
130
|
}
|
|
28
131
|
|
|
29
132
|
.block-library-post-featured-image-dimension-controls {
|
|
30
133
|
margin-bottom: $grid-unit-10;
|
|
134
|
+
|
|
31
135
|
&.scale-control-is-visible {
|
|
32
136
|
margin-bottom: $grid-unit-20;
|
|
33
137
|
}
|
package/src/post-title/edit.js
CHANGED
|
@@ -62,7 +62,7 @@ export default function PostTitleEdit( {
|
|
|
62
62
|
/>
|
|
63
63
|
) : (
|
|
64
64
|
<TagName { ...blockProps }>
|
|
65
|
-
<RawHTML key="html">{ fullTitle
|
|
65
|
+
<RawHTML key="html">{ fullTitle?.rendered }</RawHTML>
|
|
66
66
|
</TagName>
|
|
67
67
|
);
|
|
68
68
|
}
|
|
@@ -92,7 +92,7 @@ export default function PostTitleEdit( {
|
|
|
92
92
|
rel={ rel }
|
|
93
93
|
onClick={ ( event ) => event.preventDefault() }
|
|
94
94
|
>
|
|
95
|
-
<RawHTML key="html">{ fullTitle
|
|
95
|
+
<RawHTML key="html">{ fullTitle?.rendered }</RawHTML>
|
|
96
96
|
</a>
|
|
97
97
|
</TagName>
|
|
98
98
|
);
|