@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.
Files changed (193) hide show
  1. package/build/cover/edit.js +8 -3
  2. package/build/cover/edit.js.map +1 -1
  3. package/build/cover/transforms.js +2 -0
  4. package/build/cover/transforms.js.map +1 -1
  5. package/build/gallery/edit.js +1 -1
  6. package/build/gallery/edit.js.map +1 -1
  7. package/build/gallery/v1/update-gallery-modal.js +1 -1
  8. package/build/gallery/v1/update-gallery-modal.js.map +1 -1
  9. package/build/index.js +4 -3
  10. package/build/index.js.map +1 -1
  11. package/build/navigation/deprecated.js +127 -19
  12. package/build/navigation/deprecated.js.map +1 -1
  13. package/build/navigation/edit/index.js +59 -33
  14. package/build/navigation/edit/index.js.map +1 -1
  15. package/build/navigation/edit/inner-blocks.js +1 -1
  16. package/build/navigation/edit/inner-blocks.js.map +1 -1
  17. package/build/navigation/edit/navigation-menu-selector.js +2 -2
  18. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  19. package/build/navigation/edit/placeholder/index.js +16 -48
  20. package/build/navigation/edit/placeholder/index.js.map +1 -1
  21. package/build/navigation/edit/responsive-wrapper.js +5 -2
  22. package/build/navigation/edit/responsive-wrapper.js.map +1 -1
  23. package/build/navigation/edit/unsaved-inner-blocks.js +4 -35
  24. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  25. package/build/navigation/edit/use-create-navigation-menu.js +50 -0
  26. package/build/navigation/edit/use-create-navigation-menu.js.map +1 -0
  27. package/build/navigation/edit/use-generate-default-navigation-title.js +73 -0
  28. package/build/navigation/edit/use-generate-default-navigation-title.js.map +1 -0
  29. package/build/navigation/index.js +1 -1
  30. package/build/navigation/save.js +2 -2
  31. package/build/navigation/save.js.map +1 -1
  32. package/build/navigation/use-navigation-menu.js +19 -8
  33. package/build/navigation/use-navigation-menu.js.map +1 -1
  34. package/build/navigation-area/edit.js +5 -0
  35. package/build/navigation-area/edit.js.map +1 -1
  36. package/build/page-list/edit.js +40 -42
  37. package/build/page-list/edit.js.map +1 -1
  38. package/build/pattern/index.js +1 -1
  39. package/build/post-featured-image/edit.js +53 -23
  40. package/build/post-featured-image/edit.js.map +1 -1
  41. package/build/post-terms/index.js +1 -1
  42. package/build/post-title/edit.js +2 -2
  43. package/build/post-title/edit.js.map +1 -1
  44. package/build/query-pagination-next/index.js +1 -1
  45. package/build/query-pagination-previous/index.js +1 -1
  46. package/build/query-title/index.js +1 -1
  47. package/build/site-logo/index.js +1 -1
  48. package/build/site-tagline/index.js +1 -1
  49. package/build/site-title/index.js +1 -1
  50. package/build/template-part/edit/placeholder/index.js +1 -1
  51. package/build/template-part/edit/placeholder/index.js.map +1 -1
  52. package/build/template-part/index.js +2 -1
  53. package/build/template-part/index.js.map +1 -1
  54. package/build-module/cover/edit.js +8 -3
  55. package/build-module/cover/edit.js.map +1 -1
  56. package/build-module/cover/transforms.js +2 -0
  57. package/build-module/cover/transforms.js.map +1 -1
  58. package/build-module/gallery/edit.js +1 -1
  59. package/build-module/gallery/edit.js.map +1 -1
  60. package/build-module/gallery/v1/update-gallery-modal.js +1 -1
  61. package/build-module/gallery/v1/update-gallery-modal.js.map +1 -1
  62. package/build-module/index.js +4 -3
  63. package/build-module/index.js.map +1 -1
  64. package/build-module/navigation/deprecated.js +127 -19
  65. package/build-module/navigation/deprecated.js.map +1 -1
  66. package/build-module/navigation/edit/index.js +60 -33
  67. package/build-module/navigation/edit/index.js.map +1 -1
  68. package/build-module/navigation/edit/inner-blocks.js +1 -1
  69. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  70. package/build-module/navigation/edit/navigation-menu-selector.js +2 -2
  71. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  72. package/build-module/navigation/edit/placeholder/index.js +15 -45
  73. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  74. package/build-module/navigation/edit/responsive-wrapper.js +5 -2
  75. package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
  76. package/build-module/navigation/edit/unsaved-inner-blocks.js +6 -35
  77. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  78. package/build-module/navigation/edit/use-create-navigation-menu.js +36 -0
  79. package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -0
  80. package/build-module/navigation/edit/use-generate-default-navigation-title.js +57 -0
  81. package/build-module/navigation/edit/use-generate-default-navigation-title.js.map +1 -0
  82. package/build-module/navigation/index.js +1 -1
  83. package/build-module/navigation/save.js +2 -2
  84. package/build-module/navigation/save.js.map +1 -1
  85. package/build-module/navigation/use-navigation-menu.js +19 -8
  86. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  87. package/build-module/navigation-area/edit.js +4 -0
  88. package/build-module/navigation-area/edit.js.map +1 -1
  89. package/build-module/page-list/edit.js +41 -43
  90. package/build-module/page-list/edit.js.map +1 -1
  91. package/build-module/pattern/index.js +1 -1
  92. package/build-module/post-featured-image/edit.js +55 -26
  93. package/build-module/post-featured-image/edit.js.map +1 -1
  94. package/build-module/post-terms/index.js +1 -1
  95. package/build-module/post-title/edit.js +2 -2
  96. package/build-module/post-title/edit.js.map +1 -1
  97. package/build-module/query-pagination-next/index.js +1 -1
  98. package/build-module/query-pagination-previous/index.js +1 -1
  99. package/build-module/query-title/index.js +1 -1
  100. package/build-module/site-logo/index.js +1 -1
  101. package/build-module/site-tagline/index.js +1 -1
  102. package/build-module/site-title/index.js +1 -1
  103. package/build-module/template-part/edit/placeholder/index.js +2 -2
  104. package/build-module/template-part/edit/placeholder/index.js.map +1 -1
  105. package/build-module/template-part/index.js +2 -1
  106. package/build-module/template-part/index.js.map +1 -1
  107. package/build-style/code/theme-rtl.css +1 -1
  108. package/build-style/code/theme.css +1 -1
  109. package/build-style/cover/style-rtl.css +8 -2
  110. package/build-style/cover/style.css +8 -2
  111. package/build-style/editor-rtl.css +104 -53
  112. package/build-style/editor.css +104 -53
  113. package/build-style/gallery/editor-rtl.css +1 -0
  114. package/build-style/gallery/editor.css +1 -0
  115. package/build-style/navigation/style-rtl.css +41 -3
  116. package/build-style/navigation/style.css +41 -3
  117. package/build-style/post-comments-form/style-rtl.css +18 -0
  118. package/build-style/post-comments-form/style.css +18 -0
  119. package/build-style/post-featured-image/editor-rtl.css +100 -16
  120. package/build-style/post-featured-image/editor.css +100 -16
  121. package/build-style/site-logo/editor-rtl.css +2 -2
  122. package/build-style/site-logo/editor.css +2 -2
  123. package/build-style/social-links/editor-rtl.css +1 -35
  124. package/build-style/social-links/editor.css +1 -35
  125. package/build-style/style-rtl.css +67 -27
  126. package/build-style/style.css +67 -27
  127. package/build-style/theme-rtl.css +1 -1
  128. package/build-style/theme.css +1 -1
  129. package/package.json +8 -8
  130. package/src/calendar/index.php +3 -3
  131. package/src/code/theme.scss +1 -1
  132. package/src/cover/edit.js +8 -1
  133. package/src/cover/style.scss +9 -2
  134. package/src/cover/transforms.js +2 -0
  135. package/src/gallery/edit.js +1 -1
  136. package/src/gallery/editor.scss +1 -0
  137. package/src/gallery/index.php +1 -1
  138. package/src/gallery/v1/update-gallery-modal.js +1 -1
  139. package/src/home-link/index.php +1 -1
  140. package/src/image/index.php +1 -1
  141. package/src/index.js +28 -26
  142. package/src/navigation/block.json +1 -1
  143. package/src/navigation/deprecated.js +115 -13
  144. package/src/navigation/edit/index.js +68 -36
  145. package/src/navigation/edit/inner-blocks.js +2 -1
  146. package/src/navigation/edit/navigation-menu-selector.js +2 -2
  147. package/src/navigation/edit/placeholder/index.js +16 -62
  148. package/src/navigation/edit/responsive-wrapper.js +8 -1
  149. package/src/navigation/edit/unsaved-inner-blocks.js +6 -57
  150. package/src/navigation/edit/use-create-navigation-menu.js +39 -0
  151. package/src/navigation/edit/use-generate-default-navigation-title.js +79 -0
  152. package/src/navigation/index.php +171 -25
  153. package/src/navigation/save.js +2 -2
  154. package/src/navigation/style.scss +57 -5
  155. package/src/navigation/use-navigation-menu.js +20 -9
  156. package/src/navigation-area/edit.js +5 -0
  157. package/src/navigation-area/index.php +2 -1
  158. package/src/navigation-link/index.php +1 -1
  159. package/src/navigation-submenu/index.php +2 -8
  160. package/src/page-list/edit.js +35 -44
  161. package/src/page-list/index.php +10 -5
  162. package/src/pattern/block.json +1 -1
  163. package/src/post-comments-form/style.scss +20 -1
  164. package/src/post-featured-image/edit.js +58 -26
  165. package/src/post-featured-image/editor.scss +124 -20
  166. package/src/post-terms/block.json +1 -1
  167. package/src/post-title/edit.js +2 -2
  168. package/src/query-pagination-next/block.json +1 -1
  169. package/src/query-pagination-previous/block.json +1 -1
  170. package/src/query-title/block.json +1 -1
  171. package/src/site-logo/block.json +1 -1
  172. package/src/site-logo/editor.scss +3 -2
  173. package/src/site-tagline/block.json +1 -1
  174. package/src/site-title/block.json +1 -1
  175. package/src/social-links/editor.scss +1 -47
  176. package/src/style.scss +0 -1
  177. package/src/table-of-contents/index.php +1 -1
  178. package/src/template-part/block.json +2 -1
  179. package/src/template-part/edit/placeholder/index.js +2 -2
  180. package/src/template-part/index.php +2 -1
  181. package/build/navigation/edit/navigation-menu-name-modal.js +0 -55
  182. package/build/navigation/edit/navigation-menu-name-modal.js.map +0 -1
  183. package/build/navigation/edit/navigation-menu-publish-button.js +0 -53
  184. package/build/navigation/edit/navigation-menu-publish-button.js.map +0 -1
  185. package/build-module/navigation/edit/navigation-menu-name-modal.js +0 -47
  186. package/build-module/navigation/edit/navigation-menu-name-modal.js.map +0 -1
  187. package/build-module/navigation/edit/navigation-menu-publish-button.js +0 -40
  188. package/build-module/navigation/edit/navigation-menu-publish-button.js.map +0 -1
  189. package/build-style/navigation-submenu/style-rtl.css +0 -97
  190. package/build-style/navigation-submenu/style.css +0 -97
  191. package/src/navigation/edit/navigation-menu-name-modal.js +0 -69
  192. package/src/navigation/edit/navigation-menu-publish-button.js +0 -57
  193. 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( navigationMenuId ) {
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
- navigationMenuId,
20
+ ref,
20
21
  ];
21
- const navigationMenu = navigationMenuId
22
+ const rawNavigationMenu = ref
23
+ ? getEntityRecord( ...navigationMenuSingleArgs )
24
+ : null;
25
+ let navigationMenu = ref
22
26
  ? getEditedEntityRecord( ...navigationMenuSingleArgs )
23
27
  : null;
24
- const hasResolvedNavigationMenu = navigationMenuId
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 = navigationMenuId
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
- ! navigationMenuId ||
48
- ( hasResolvedNavigationMenu && ! navigationMenu ),
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
- [ navigationMenuId ]
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,8 @@
2
2
  /**
3
3
  * Server-side rendering of the `core/navigation-area` block.
4
4
  *
5
- * @package gutenberg
5
+ * @deprecated 5.9.0 See https://github.com/WordPress/gutenberg/issues/36524
6
+ * @package WordPress
6
7
  */
7
8
 
8
9
  /**
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * Server-side rendering of the `core/navigation-link` block.
4
4
  *
5
- * @package gutenberg
5
+ * @package WordPress
6
6
  */
7
7
 
8
8
  /**
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * Server-side rendering of the `core/navigation-submenu` block.
4
4
  *
5
- * @package gutenberg
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['isTopLevelLink'] ) ? ( ! $attributes['isTopLevelLink'] ) : false;
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'] &&
@@ -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 { useEffect, useState, memo } from '@wordpress/element';
18
- import apiFetch from '@wordpress/api-fetch';
19
- import { addQueryArgs } from '@wordpress/url';
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 === null && (
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 [ pagesByParentId, setPagesByParentId ] = useState( null );
99
- const [ totalPages, setTotalPages ] = useState( null );
100
-
101
- useEffect( () => {
102
- async function performFetch() {
103
- setPagesByParentId( null );
104
- setTotalPages( null );
105
-
106
- let pages = await apiFetch( {
107
- path: addQueryArgs( '/wp/v2/pages', {
108
- orderby: 'menu_order',
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
- pagesByParentId,
138
- totalPages,
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( {
@@ -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', gutenberg_experimental_to_kebab_case( $context['textColor'] ) );
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', gutenberg_experimental_to_kebab_case( $context['backgroundColor'] ) );
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', gutenberg_experimental_to_kebab_case( $context['overlayTextColor'] ) );
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', gutenberg_experimental_to_kebab_case( $context['overlayBackgroundColor'] ) );
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 . ' "href="' . esc_url( $page['link'] ) . '"' . $aria_current . '>' . wp_kses(
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;
@@ -2,7 +2,7 @@
2
2
  "apiVersion": 2,
3
3
  "name": "core/pattern",
4
4
  "title": "Pattern",
5
- "category": "design",
5
+ "category": "theme",
6
6
  "description": "Show a block pattern.",
7
7
  "supports": {
8
8
  "html": false,
@@ -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
- withNotices,
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 { postFeaturedImage } from '@wordpress/icons';
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-image_placeholder">
31
- <Icon icon={ postFeaturedImage } />
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
- function onUploadError( message ) {
66
- noticeOperations.removeAllNotices();
67
- noticeOperations.createErrorNotice( message );
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
- labels={ {
83
- title: __( 'Featured image' ),
84
- instructions: __(
85
- 'Upload a media file or pick one from your media library.'
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 <PostFeaturedImageWithNotices { ...props } />;
178
+ return <PostFeaturedImageDisplay { ...props } />;
147
179
  }
@@ -1,33 +1,137 @@
1
- div[data-type="core/post-featured-image"] {
2
- img {
3
- max-width: 100%;
4
- height: auto;
5
- display: block;
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
- .editor-styles-wrapper {
10
- .post-featured-image_placeholder {
11
- display: flex;
12
- flex-direction: row;
11
+ // Style the placeholder.
12
+ .wp-block-post-featured-image__placeholder,
13
+ .components-placeholder {
14
+ justify-content: center;
13
15
  align-items: center;
14
- border-radius: $radius-block-ui;
15
- background-color: $white;
16
- box-shadow: inset 0 0 0 $border-width $gray-900;
17
- padding: $grid-unit-15;
18
- svg {
19
- margin-right: $grid-unit-15;
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
- p {
22
- font-family: $default-font;
23
- font-size: $default-font-size;
24
- margin: 0;
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
  }
@@ -2,7 +2,7 @@
2
2
  "apiVersion": 2,
3
3
  "name": "core/post-terms",
4
4
  "title": "Post Terms",
5
- "category": "design",
5
+ "category": "theme",
6
6
  "description": "Post terms.",
7
7
  "textdomain": "default",
8
8
  "attributes": {
@@ -62,7 +62,7 @@ export default function PostTitleEdit( {
62
62
  />
63
63
  ) : (
64
64
  <TagName { ...blockProps }>
65
- <RawHTML key="html">{ fullTitle.rendered }</RawHTML>
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.rendered }</RawHTML>
95
+ <RawHTML key="html">{ fullTitle?.rendered }</RawHTML>
96
96
  </a>
97
97
  </TagName>
98
98
  );