@wordpress/block-library 9.42.0 → 9.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/form-input/edit.cjs +36 -29
  3. package/build/form-input/edit.cjs.map +2 -2
  4. package/build/form-input/variations.cjs +10 -0
  5. package/build/form-input/variations.cjs.map +2 -2
  6. package/build/group/block.json +3 -1
  7. package/build/image/image.cjs +13 -4
  8. package/build/image/image.cjs.map +2 -2
  9. package/build/latest-comments/deprecated.cjs +33 -0
  10. package/build/latest-comments/deprecated.cjs.map +2 -2
  11. package/build/list-item/block.json +1 -0
  12. package/build/navigation/edit/index.cjs +123 -119
  13. package/build/navigation/edit/index.cjs.map +3 -3
  14. package/build/navigation/edit/navigation-menu-selector.cjs +2 -1
  15. package/build/navigation/edit/navigation-menu-selector.cjs.map +2 -2
  16. package/build/site-logo/edit.cjs +19 -13
  17. package/build/site-logo/edit.cjs.map +3 -3
  18. package/build/site-tagline/deprecated.cjs +2 -1
  19. package/build/site-tagline/deprecated.cjs.map +2 -2
  20. package/build/tab/save.cjs +2 -4
  21. package/build/tab/save.cjs.map +2 -2
  22. package/build/tabs/save.cjs +2 -4
  23. package/build/tabs/save.cjs.map +2 -2
  24. package/build/utils/media-control.cjs +1 -1
  25. package/build/utils/media-control.cjs.map +2 -2
  26. package/build-module/form-input/edit.mjs +36 -29
  27. package/build-module/form-input/edit.mjs.map +2 -2
  28. package/build-module/form-input/variations.mjs +10 -0
  29. package/build-module/form-input/variations.mjs.map +2 -2
  30. package/build-module/group/block.json +3 -1
  31. package/build-module/image/image.mjs +13 -4
  32. package/build-module/image/image.mjs.map +2 -2
  33. package/build-module/latest-comments/deprecated.mjs +33 -0
  34. package/build-module/latest-comments/deprecated.mjs.map +2 -2
  35. package/build-module/list-item/block.json +1 -0
  36. package/build-module/navigation/edit/index.mjs +123 -119
  37. package/build-module/navigation/edit/index.mjs.map +2 -2
  38. package/build-module/navigation/edit/navigation-menu-selector.mjs +2 -1
  39. package/build-module/navigation/edit/navigation-menu-selector.mjs.map +2 -2
  40. package/build-module/site-logo/edit.mjs +21 -14
  41. package/build-module/site-logo/edit.mjs.map +2 -2
  42. package/build-module/site-tagline/deprecated.mjs +2 -1
  43. package/build-module/site-tagline/deprecated.mjs.map +2 -2
  44. package/build-module/tab/save.mjs +2 -4
  45. package/build-module/tab/save.mjs.map +2 -2
  46. package/build-module/tabs/save.mjs +2 -4
  47. package/build-module/tabs/save.mjs.map +2 -2
  48. package/build-module/utils/media-control.mjs +1 -1
  49. package/build-module/utils/media-control.mjs.map +2 -2
  50. package/build-style/editor-rtl.css +15 -5
  51. package/build-style/editor.css +15 -5
  52. package/build-style/form-input/editor-rtl.css +6 -5
  53. package/build-style/form-input/editor.css +6 -5
  54. package/build-style/icon/editor-rtl.css +5 -0
  55. package/build-style/icon/editor.css +5 -0
  56. package/build-style/image/editor-rtl.css +4 -0
  57. package/build-style/image/editor.css +4 -0
  58. package/build-style/navigation/style-rtl.css +4 -1
  59. package/build-style/navigation/style.css +4 -1
  60. package/build-style/style-rtl.css +4 -1
  61. package/build-style/style.css +4 -1
  62. package/package.json +38 -38
  63. package/src/form-input/edit.js +19 -15
  64. package/src/form-input/editor.scss +6 -6
  65. package/src/form-input/variations.js +10 -0
  66. package/src/group/block.json +3 -1
  67. package/src/home-link/index.php +14 -33
  68. package/src/icon/editor.scss +5 -0
  69. package/src/image/editor.scss +5 -0
  70. package/src/image/image.js +18 -3
  71. package/src/latest-comments/deprecated.js +33 -0
  72. package/src/list-item/block.json +1 -0
  73. package/src/loginout/index.php +13 -0
  74. package/src/navigation/edit/index.js +134 -130
  75. package/src/navigation/edit/navigation-menu-selector.js +2 -1
  76. package/src/navigation/style.scss +5 -3
  77. package/src/navigation-link/index.php +10 -38
  78. package/src/navigation-link/shared/build-css-font-sizes.php +43 -0
  79. package/src/navigation-submenu/index.php +10 -38
  80. package/src/page-list/index.php +14 -41
  81. package/src/site-logo/edit.js +24 -13
  82. package/src/site-tagline/deprecated.js +1 -0
  83. package/src/tab/save.js +2 -6
  84. package/src/tabs/save.js +2 -6
  85. package/src/utils/media-control.js +3 -1
@@ -966,16 +966,7 @@ function Navigation( {
966
966
 
967
967
  if ( hasUnsavedBlocks && ! isCreatingNavigationMenu ) {
968
968
  return (
969
- <TagName
970
- { ...blockProps }
971
- aria-describedby={
972
- ! isPlaceholder ? accessibleDescriptionId : undefined
973
- }
974
- >
975
- <AccessibleDescription id={ accessibleDescriptionId }>
976
- { __( 'Unsaved Navigation Menu.' ) }
977
- </AccessibleDescription>
978
-
969
+ <>
979
970
  <MenuInspectorControls
980
971
  clientId={ clientId }
981
972
  createNavigationMenuIsSuccess={
@@ -992,26 +983,36 @@ function Navigation( {
992
983
  blockEditingMode={ blockEditingMode }
993
984
  />
994
985
  { blockEditingMode === 'default' && stylingInspectorControls }
995
- <ResponsiveWrapper
996
- id={ clientId }
997
- onToggle={ setResponsiveMenuVisibility }
998
- isOpen={ isResponsiveMenuOpen }
999
- hasIcon={ hasIcon }
1000
- icon={ icon }
1001
- isResponsive={ isResponsive }
1002
- isHiddenByDefault={ isHiddenByDefault }
1003
- overlayBackgroundColor={ overlayBackgroundColor }
1004
- overlayTextColor={ overlayTextColor }
1005
- overlay={ overlay }
1006
- onNavigateToEntityRecord={ onNavigateToEntityRecord }
986
+ <TagName
987
+ { ...blockProps }
988
+ aria-describedby={
989
+ ! isPlaceholder ? accessibleDescriptionId : undefined
990
+ }
1007
991
  >
1008
- <UnsavedInnerBlocks
1009
- createNavigationMenu={ createNavigationMenu }
1010
- blocks={ uncontrolledInnerBlocks }
1011
- hasSelection={ isSelected || isInnerBlockSelected }
1012
- />
1013
- </ResponsiveWrapper>
1014
- </TagName>
992
+ <AccessibleDescription id={ accessibleDescriptionId }>
993
+ { __( 'Unsaved Navigation Menu.' ) }
994
+ </AccessibleDescription>
995
+ <ResponsiveWrapper
996
+ id={ clientId }
997
+ onToggle={ setResponsiveMenuVisibility }
998
+ isOpen={ isResponsiveMenuOpen }
999
+ hasIcon={ hasIcon }
1000
+ icon={ icon }
1001
+ isResponsive={ isResponsive }
1002
+ isHiddenByDefault={ isHiddenByDefault }
1003
+ overlayBackgroundColor={ overlayBackgroundColor }
1004
+ overlayTextColor={ overlayTextColor }
1005
+ overlay={ overlay }
1006
+ onNavigateToEntityRecord={ onNavigateToEntityRecord }
1007
+ >
1008
+ <UnsavedInnerBlocks
1009
+ createNavigationMenu={ createNavigationMenu }
1010
+ blocks={ uncontrolledInnerBlocks }
1011
+ hasSelection={ isSelected || isInnerBlockSelected }
1012
+ />
1013
+ </ResponsiveWrapper>
1014
+ </TagName>
1015
+ </>
1015
1016
  );
1016
1017
  }
1017
1018
 
@@ -1019,7 +1020,7 @@ function Navigation( {
1019
1020
  // TODO - the user should be able to select a new one?
1020
1021
  if ( ref && isNavigationMenuMissing ) {
1021
1022
  return (
1022
- <TagName { ...blockProps }>
1023
+ <>
1023
1024
  <MenuInspectorControls
1024
1025
  clientId={ clientId }
1025
1026
  createNavigationMenuIsSuccess={
@@ -1035,10 +1036,12 @@ function Navigation( {
1035
1036
  isLoading={ isLoading }
1036
1037
  blockEditingMode={ blockEditingMode }
1037
1038
  />
1038
- <DeletedNavigationWarning
1039
- onCreateNew={ createUntitledEmptyNavigationMenu }
1040
- />
1041
- </TagName>
1039
+ <TagName { ...blockProps }>
1040
+ <DeletedNavigationWarning
1041
+ onCreateNew={ createUntitledEmptyNavigationMenu }
1042
+ />
1043
+ </TagName>
1044
+ </>
1042
1045
  );
1043
1046
  }
1044
1047
 
@@ -1088,105 +1091,106 @@ function Navigation( {
1088
1091
  }
1089
1092
 
1090
1093
  return (
1091
- <EntityProvider kind="postType" type="wp_navigation" id={ ref }>
1092
- <RecursionProvider uniqueId={ recursionId }>
1093
- <MenuInspectorControls
1094
- clientId={ clientId }
1095
- createNavigationMenuIsSuccess={
1096
- createNavigationMenuIsSuccess
1097
- }
1098
- createNavigationMenuIsError={ createNavigationMenuIsError }
1099
- currentMenuId={ ref }
1100
- isNavigationMenuMissing={ isNavigationMenuMissing }
1101
- isManageMenusButtonDisabled={ isManageMenusButtonDisabled }
1102
- onCreateNew={ createUntitledEmptyNavigationMenu }
1103
- onSelectClassicMenu={ onSelectClassicMenu }
1104
- onSelectNavigationMenu={ onSelectNavigationMenu }
1105
- isLoading={ isLoading }
1106
- blockEditingMode={ blockEditingMode }
1107
- />
1108
- { blockEditingMode === 'default' && stylingInspectorControls }
1109
- { blockEditingMode === 'contentOnly' && isEntityAvailable && (
1110
- <NavigationAddPageButton clientId={ clientId } />
1111
- ) }
1112
- { blockEditingMode === 'default' && isEntityAvailable && (
1113
- <InspectorControls group="advanced">
1114
- { hasResolvedCanUserUpdateNavigationMenu &&
1115
- canUserUpdateNavigationMenu && (
1116
- <NavigationMenuNameControl />
1117
- ) }
1118
- { hasResolvedCanUserDeleteNavigationMenu &&
1119
- canUserDeleteNavigationMenu && (
1120
- <NavigationMenuDeleteControl
1121
- onDelete={ () => {
1122
- replaceInnerBlocks( clientId, [] );
1123
- showNavigationMenuStatusNotice(
1124
- __(
1125
- 'Navigation Menu successfully deleted.'
1126
- )
1127
- );
1128
- } }
1129
- />
1130
- ) }
1131
- <ManageMenusButton
1132
- disabled={ isManageMenusButtonDisabled }
1133
- className="wp-block-navigation-manage-menus-button"
1134
- />
1135
- </InspectorControls>
1136
- ) }
1137
-
1138
- <TagName
1139
- { ...blockProps }
1140
- aria-describedby={
1141
- ! isPlaceholder && ! isLoading
1142
- ? accessibleDescriptionId
1143
- : undefined
1144
- }
1145
- >
1146
- { isLoading && ! isHiddenByDefault && (
1147
- <div className="wp-block-navigation__loading-indicator-container">
1148
- <Spinner className="wp-block-navigation__loading-indicator" />
1149
- </div>
1150
- ) }
1151
-
1152
- { ( ! isLoading || isHiddenByDefault ) && (
1153
- <>
1154
- <AccessibleMenuDescription
1155
- id={ accessibleDescriptionId }
1156
- />
1157
- <ResponsiveWrapper
1158
- id={ clientId }
1159
- onToggle={ setResponsiveMenuVisibility }
1160
- hasIcon={ hasIcon }
1161
- icon={ icon }
1162
- isOpen={ isResponsiveMenuOpen }
1163
- isResponsive={ isResponsive }
1164
- isHiddenByDefault={ isHiddenByDefault }
1165
- overlayBackgroundColor={
1166
- overlayBackgroundColor
1167
- }
1168
- overlayTextColor={ overlayTextColor }
1169
- overlay={ overlay }
1170
- onNavigateToEntityRecord={
1171
- onNavigateToEntityRecord
1172
- }
1173
- >
1174
- { isEntityAvailable && (
1175
- <NavigationInnerBlocks
1176
- clientId={ clientId }
1177
- hasCustomPlaceholder={
1178
- !! CustomPlaceholder
1179
- }
1180
- templateLock={ templateLock }
1181
- orientation={ orientation }
1094
+ <>
1095
+ <MenuInspectorControls
1096
+ clientId={ clientId }
1097
+ createNavigationMenuIsSuccess={ createNavigationMenuIsSuccess }
1098
+ createNavigationMenuIsError={ createNavigationMenuIsError }
1099
+ currentMenuId={ ref }
1100
+ isNavigationMenuMissing={ isNavigationMenuMissing }
1101
+ isManageMenusButtonDisabled={ isManageMenusButtonDisabled }
1102
+ onCreateNew={ createUntitledEmptyNavigationMenu }
1103
+ onSelectClassicMenu={ onSelectClassicMenu }
1104
+ onSelectNavigationMenu={ onSelectNavigationMenu }
1105
+ isLoading={ isLoading }
1106
+ blockEditingMode={ blockEditingMode }
1107
+ />
1108
+ { blockEditingMode === 'default' && stylingInspectorControls }
1109
+ <EntityProvider kind="postType" type="wp_navigation" id={ ref }>
1110
+ <RecursionProvider uniqueId={ recursionId }>
1111
+ { blockEditingMode === 'contentOnly' &&
1112
+ isEntityAvailable && (
1113
+ <NavigationAddPageButton clientId={ clientId } />
1114
+ ) }
1115
+ { blockEditingMode === 'default' && isEntityAvailable && (
1116
+ <InspectorControls group="advanced">
1117
+ { hasResolvedCanUserUpdateNavigationMenu &&
1118
+ canUserUpdateNavigationMenu && (
1119
+ <NavigationMenuNameControl />
1120
+ ) }
1121
+ { hasResolvedCanUserDeleteNavigationMenu &&
1122
+ canUserDeleteNavigationMenu && (
1123
+ <NavigationMenuDeleteControl
1124
+ onDelete={ () => {
1125
+ replaceInnerBlocks( clientId, [] );
1126
+ showNavigationMenuStatusNotice(
1127
+ __(
1128
+ 'Navigation Menu successfully deleted.'
1129
+ )
1130
+ );
1131
+ } }
1182
1132
  />
1183
1133
  ) }
1184
- </ResponsiveWrapper>
1185
- </>
1134
+ <ManageMenusButton
1135
+ disabled={ isManageMenusButtonDisabled }
1136
+ className="wp-block-navigation-manage-menus-button"
1137
+ />
1138
+ </InspectorControls>
1186
1139
  ) }
1187
- </TagName>
1188
- </RecursionProvider>
1189
- </EntityProvider>
1140
+
1141
+ <TagName
1142
+ { ...blockProps }
1143
+ aria-describedby={
1144
+ ! isPlaceholder && ! isLoading
1145
+ ? accessibleDescriptionId
1146
+ : undefined
1147
+ }
1148
+ >
1149
+ { isLoading && ! isHiddenByDefault && (
1150
+ <div className="wp-block-navigation__loading-indicator-container">
1151
+ <Spinner className="wp-block-navigation__loading-indicator" />
1152
+ </div>
1153
+ ) }
1154
+
1155
+ { ( ! isLoading || isHiddenByDefault ) && (
1156
+ <>
1157
+ <AccessibleMenuDescription
1158
+ id={ accessibleDescriptionId }
1159
+ />
1160
+ <ResponsiveWrapper
1161
+ id={ clientId }
1162
+ onToggle={ setResponsiveMenuVisibility }
1163
+ hasIcon={ hasIcon }
1164
+ icon={ icon }
1165
+ isOpen={ isResponsiveMenuOpen }
1166
+ isResponsive={ isResponsive }
1167
+ isHiddenByDefault={ isHiddenByDefault }
1168
+ overlayBackgroundColor={
1169
+ overlayBackgroundColor
1170
+ }
1171
+ overlayTextColor={ overlayTextColor }
1172
+ overlay={ overlay }
1173
+ onNavigateToEntityRecord={
1174
+ onNavigateToEntityRecord
1175
+ }
1176
+ >
1177
+ { isEntityAvailable && (
1178
+ <NavigationInnerBlocks
1179
+ clientId={ clientId }
1180
+ hasCustomPlaceholder={
1181
+ !! CustomPlaceholder
1182
+ }
1183
+ templateLock={ templateLock }
1184
+ orientation={ orientation }
1185
+ />
1186
+ ) }
1187
+ </ResponsiveWrapper>
1188
+ </>
1189
+ ) }
1190
+ </TagName>
1191
+ </RecursionProvider>
1192
+ </EntityProvider>
1193
+ </>
1190
1194
  );
1191
1195
  }
1192
1196
 
@@ -69,7 +69,8 @@ function NavigationMenuSelector( {
69
69
  const [ currentTitle ] = useEntityProp(
70
70
  'postType',
71
71
  'wp_navigation',
72
- 'title'
72
+ 'title',
73
+ currentMenuId
73
74
  );
74
75
 
75
76
  const menuChoices = useMemo( () => {
@@ -27,9 +27,6 @@ $navigation-icon-size: 24px;
27
27
  ul,
28
28
  ul li {
29
29
  list-style: none;
30
-
31
- // Overrides generic ".entry-content li" styles on the front end.
32
- padding: 0;
33
30
  }
34
31
 
35
32
  // Menu item container.
@@ -156,6 +153,11 @@ $navigation-icon-size: 24px;
156
153
  }
157
154
  }
158
155
 
156
+ // Low specificity padding to not override global styles.
157
+ :where(.wp-block-navigation) ul li {
158
+ padding: 0;
159
+ }
160
+
159
161
  // Styles for submenu flyout.
160
162
  // These are separated out with reduced specificity to allow better inheritance from Global Styles.
161
163
  .wp-block-navigation .has-child {
@@ -7,6 +7,7 @@
7
7
 
8
8
  require_once __DIR__ . '/navigation-link/shared/item-should-render.php';
9
9
  require_once __DIR__ . '/navigation-link/shared/render-submenu-icon.php';
10
+ require_once __DIR__ . '/navigation-link/shared/build-css-font-sizes.php';
10
11
 
11
12
  /**
12
13
  * Build an array with CSS classes and inline styles defining the colors
@@ -80,43 +81,6 @@ function block_core_navigation_link_build_css_colors( $context, $attributes, $is
80
81
  return $colors;
81
82
  }
82
83
 
83
- /**
84
- * Build an array with CSS classes and inline styles defining the font sizes
85
- * which will be applied to the navigation markup in the front-end.
86
- *
87
- * @since 5.9.0
88
- *
89
- * @param array $context Navigation block context.
90
- * @return array Font size CSS classes and inline styles.
91
- */
92
- function block_core_navigation_link_build_css_font_sizes( $context ) {
93
- // CSS classes.
94
- $font_sizes = array(
95
- 'css_classes' => array(),
96
- 'inline_styles' => '',
97
- );
98
-
99
- $has_named_font_size = array_key_exists( 'fontSize', $context );
100
- $has_custom_font_size = isset( $context['style']['typography']['fontSize'] );
101
-
102
- if ( $has_named_font_size ) {
103
- // Add the font size class.
104
- $font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
105
- } elseif ( $has_custom_font_size ) {
106
- // Add the custom font size inline style.
107
- $font_sizes['inline_styles'] = sprintf(
108
- 'font-size: %s;',
109
- wp_get_typography_font_size_value(
110
- array(
111
- 'size' => $context['style']['typography']['fontSize'],
112
- )
113
- )
114
- );
115
- }
116
-
117
- return $font_sizes;
118
- }
119
-
120
84
  /**
121
85
  * Decodes a url if it's encoded, returning the same url if not.
122
86
  *
@@ -174,7 +138,15 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
174
138
  return '';
175
139
  }
176
140
 
177
- $font_sizes = block_core_navigation_link_build_css_font_sizes( $block->context );
141
+ // The build system prefixes this function with "gutenberg_" to avoid
142
+ // collisions with the core version. Until this function is backported to
143
+ // core, we need to guard its use and only call the prefixed name in
144
+ // the plugin.
145
+ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
146
+ $font_sizes = gutenberg_block_core_shared_navigation_build_css_font_sizes( $block->context );
147
+ } else {
148
+ $font_sizes = block_core_shared_navigation_build_css_font_sizes( $block->context );
149
+ }
178
150
  $classes = array_merge(
179
151
  $font_sizes['css_classes']
180
152
  );
@@ -0,0 +1,43 @@
1
+ <?php
2
+ /**
3
+ * Shared helper function for building CSS font sizes in navigation blocks.
4
+ *
5
+ * @package WordPress
6
+ */
7
+
8
+ /**
9
+ * Build an array with CSS classes and inline styles defining the font sizes
10
+ * which will be applied to the navigation markup in the front-end.
11
+ *
12
+ * @since 7.1.0
13
+ *
14
+ * @param array $context Navigation block context.
15
+ * @return array Font size CSS classes and inline styles.
16
+ */
17
+ function block_core_shared_navigation_build_css_font_sizes( $context ) {
18
+ // CSS classes.
19
+ $font_sizes = array(
20
+ 'css_classes' => array(),
21
+ 'inline_styles' => '',
22
+ );
23
+
24
+ $has_named_font_size = array_key_exists( 'fontSize', $context );
25
+ $has_custom_font_size = isset( $context['style']['typography']['fontSize'] );
26
+
27
+ if ( $has_named_font_size ) {
28
+ // Add the font size class.
29
+ $font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
30
+ } elseif ( $has_custom_font_size ) {
31
+ // Add the custom font size inline style.
32
+ $font_sizes['inline_styles'] = sprintf(
33
+ 'font-size: %s;',
34
+ wp_get_typography_font_size_value(
35
+ array(
36
+ 'size' => $context['style']['typography']['fontSize'],
37
+ )
38
+ )
39
+ );
40
+ }
41
+
42
+ return $font_sizes;
43
+ }
@@ -7,6 +7,7 @@
7
7
 
8
8
  require_once __DIR__ . '/navigation-link/shared/item-should-render.php';
9
9
  require_once __DIR__ . '/navigation-link/shared/render-submenu-icon.php';
10
+ require_once __DIR__ . '/navigation-link/shared/build-css-font-sizes.php';
10
11
 
11
12
  /**
12
13
  * Returns the submenu visibility value with backward compatibility
@@ -49,43 +50,6 @@ function block_core_navigation_submenu_get_submenu_visibility( $context ) {
49
50
  return $submenu_visibility ?? 'hover';
50
51
  }
51
52
 
52
- /**
53
- * Build an array with CSS classes and inline styles defining the font sizes
54
- * which will be applied to the navigation markup in the front-end.
55
- *
56
- * @since 5.9.0
57
- *
58
- * @param array $context Navigation block context.
59
- * @return array Font size CSS classes and inline styles.
60
- */
61
- function block_core_navigation_submenu_build_css_font_sizes( $context ) {
62
- // CSS classes.
63
- $font_sizes = array(
64
- 'css_classes' => array(),
65
- 'inline_styles' => '',
66
- );
67
-
68
- $has_named_font_size = array_key_exists( 'fontSize', $context );
69
- $has_custom_font_size = isset( $context['style']['typography']['fontSize'] );
70
-
71
- if ( $has_named_font_size ) {
72
- // Add the font size class.
73
- $font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
74
- } elseif ( $has_custom_font_size ) {
75
- // Add the custom font size inline style.
76
- $font_sizes['inline_styles'] = sprintf(
77
- 'font-size: %s;',
78
- wp_get_typography_font_size_value(
79
- array(
80
- 'size' => $context['style']['typography']['fontSize'],
81
- )
82
- )
83
- );
84
- }
85
-
86
- return $font_sizes;
87
- }
88
-
89
53
  /**
90
54
  * Renders the `core/navigation-submenu` block.
91
55
  *
@@ -110,7 +74,15 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
110
74
  return '';
111
75
  }
112
76
 
113
- $font_sizes = block_core_navigation_submenu_build_css_font_sizes( $block->context );
77
+ // The build system prefixes this function with "gutenberg_" to avoid
78
+ // collisions with the core version. Until this function is backported to
79
+ // core, we need to guard its use and only call the prefixed name in
80
+ // the plugin.
81
+ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
82
+ $font_sizes = gutenberg_block_core_shared_navigation_build_css_font_sizes( $block->context );
83
+ } else {
84
+ $font_sizes = block_core_shared_navigation_build_css_font_sizes( $block->context );
85
+ }
114
86
  $style_attribute = $font_sizes['inline_styles'];
115
87
 
116
88
  // Render inner blocks first to check if any menu items will actually display.
@@ -5,6 +5,8 @@
5
5
  * @package WordPress
6
6
  */
7
7
 
8
+ require_once __DIR__ . '/navigation-link/shared/build-css-font-sizes.php';
9
+
8
10
  /**
9
11
  * Returns the submenu visibility value with backward compatibility
10
12
  * for the deprecated openSubmenusOnClick attribute.
@@ -123,44 +125,6 @@ function block_core_page_list_build_css_colors( $attributes, $context ) {
123
125
 
124
126
  return $colors;
125
127
  }
126
-
127
- /**
128
- * Build an array with CSS classes and inline styles defining the font sizes
129
- * which will be applied to the pages markup in the front-end when it is a descendant of navigation.
130
- *
131
- * @since 5.8.0
132
- *
133
- * @param array $context Navigation block context.
134
- * @return array Font size CSS classes and inline styles.
135
- */
136
- function block_core_page_list_build_css_font_sizes( $context ) {
137
- // CSS classes.
138
- $font_sizes = array(
139
- 'css_classes' => array(),
140
- 'inline_styles' => '',
141
- );
142
-
143
- $has_named_font_size = array_key_exists( 'fontSize', $context );
144
- $has_custom_font_size = isset( $context['style']['typography']['fontSize'] );
145
-
146
- if ( $has_named_font_size ) {
147
- // Add the font size class.
148
- $font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
149
- } elseif ( $has_custom_font_size ) {
150
- // Add the custom font size inline style.
151
- $font_sizes['inline_styles'] = sprintf(
152
- 'font-size: %s;',
153
- wp_get_typography_font_size_value(
154
- array(
155
- 'size' => $context['style']['typography']['fontSize'],
156
- )
157
- )
158
- );
159
- }
160
-
161
- return $font_sizes;
162
- }
163
-
164
128
  /**
165
129
  * Outputs Page list markup from an array of pages with nested children.
166
130
  *
@@ -342,12 +306,21 @@ function render_block_core_page_list( $attributes, $content, $block ) {
342
306
  }
343
307
  }
344
308
 
345
- $colors = block_core_page_list_build_css_colors( $attributes, $block->context );
346
- $font_sizes = block_core_page_list_build_css_font_sizes( $block->context );
347
- $classes = array_merge(
309
+ $colors = block_core_page_list_build_css_colors( $attributes, $block->context );
310
+ // The build system prefixes this function with "gutenberg_" to avoid
311
+ // collisions with the core version. Until this function is backported to
312
+ // core, we need to guard its use and only call the prefixed name in
313
+ // the plugin.
314
+ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
315
+ $font_sizes = gutenberg_block_core_shared_navigation_build_css_font_sizes( $block->context );
316
+ } else {
317
+ $font_sizes = block_core_shared_navigation_build_css_font_sizes( $block->context );
318
+ }
319
+ $classes = array_merge(
348
320
  $colors['css_classes'],
349
321
  $font_sizes['css_classes']
350
322
  );
323
+
351
324
  $style_attribute = ( $colors['inline_styles'] . $font_sizes['inline_styles'] );
352
325
  $css_classes = trim( implode( ' ', $classes ) );
353
326
 
@@ -35,6 +35,7 @@ import {
35
35
  store as blockEditorStore,
36
36
  __experimentalImageEditor as ImageEditor,
37
37
  useBlockEditingMode,
38
+ privateApis as blockEditorPrivateApis,
38
39
  } from '@wordpress/block-editor';
39
40
  import { useSelect, useDispatch } from '@wordpress/data';
40
41
  import { store as coreStore } from '@wordpress/core-data';
@@ -46,9 +47,11 @@ import { store as noticesStore } from '@wordpress/notices';
46
47
  */
47
48
  import { MIN_SIZE } from '../image/constants';
48
49
  import { MediaControl, MediaControlPreview } from '../utils/media-control';
50
+ import { unlock } from '../lock-unlock';
49
51
  import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
50
52
 
51
53
  const ALLOWED_MEDIA_TYPES = [ 'image' ];
54
+ const { mediaEditKey } = unlock( blockEditorPrivateApis );
52
55
 
53
56
  const SiteLogo = ( {
54
57
  alt,
@@ -75,18 +78,22 @@ const SiteLogo = ( {
75
78
  const blockEditingMode = useBlockEditingMode();
76
79
  const isContentOnlyMode = blockEditingMode === 'contentOnly';
77
80
 
78
- const { imageEditing, maxWidth, title } = useSelect( ( select ) => {
79
- const settings = select( blockEditorStore ).getSettings();
80
- const siteEntities = select( coreStore ).getEntityRecord(
81
- 'root',
82
- '__unstableBase'
83
- );
84
- return {
85
- title: siteEntities?.name,
86
- imageEditing: settings.imageEditing,
87
- maxWidth: settings.maxWidth,
88
- };
89
- }, [] );
81
+ const { imageEditing, maxWidth, title, editMediaEntity } = useSelect(
82
+ ( select ) => {
83
+ const settings = select( blockEditorStore ).getSettings();
84
+ const siteEntities = select( coreStore ).getEntityRecord(
85
+ 'root',
86
+ '__unstableBase'
87
+ );
88
+ return {
89
+ title: siteEntities?.name,
90
+ imageEditing: settings.imageEditing,
91
+ maxWidth: settings.maxWidth,
92
+ editMediaEntity: settings?.[ mediaEditKey ],
93
+ };
94
+ },
95
+ []
96
+ );
90
97
 
91
98
  useEffect( () => {
92
99
  // Turn the `Use as site icon` toggle off if it is on but the logo and icon have
@@ -200,7 +207,11 @@ const SiteLogo = ( {
200
207
  /* eslint-enable no-lonely-if */
201
208
 
202
209
  const canEditImage =
203
- logoId && naturalWidth && naturalHeight && imageEditing;
210
+ logoId &&
211
+ naturalWidth &&
212
+ naturalHeight &&
213
+ imageEditing &&
214
+ !! editMediaEntity;
204
215
 
205
216
  // Hide crop and dimensions editing in write mode
206
217
  const shouldShowCropAndDimensions = ! isContentOnlyMode;
@@ -11,6 +11,7 @@ const v2 = {
11
11
  },
12
12
  level: {
13
13
  type: 'number',
14
+ default: 0,
14
15
  },
15
16
  levelOptions: {
16
17
  type: 'array',