@wordpress/block-library 9.41.1-next.v.202603161435.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 (109) hide show
  1. package/CHANGELOG.md +4 -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/html/modal.cjs +151 -229
  8. package/build/html/modal.cjs.map +2 -2
  9. package/build/image/image.cjs +13 -4
  10. package/build/image/image.cjs.map +2 -2
  11. package/build/latest-comments/deprecated.cjs +33 -0
  12. package/build/latest-comments/deprecated.cjs.map +2 -2
  13. package/build/list-item/block.json +1 -0
  14. package/build/navigation/edit/index.cjs +123 -119
  15. package/build/navigation/edit/index.cjs.map +3 -3
  16. package/build/navigation/edit/navigation-menu-selector.cjs +2 -1
  17. package/build/navigation/edit/navigation-menu-selector.cjs.map +2 -2
  18. package/build/post-date/block.json +1 -3
  19. package/build/post-date/deprecated.cjs +82 -6
  20. package/build/post-date/deprecated.cjs.map +3 -3
  21. package/build/post-date/edit.cjs +49 -62
  22. package/build/post-date/edit.cjs.map +3 -3
  23. package/build/site-logo/edit.cjs +19 -13
  24. package/build/site-logo/edit.cjs.map +3 -3
  25. package/build/site-tagline/deprecated.cjs +2 -1
  26. package/build/site-tagline/deprecated.cjs.map +2 -2
  27. package/build/site-title/index.cjs +5 -1
  28. package/build/site-title/index.cjs.map +2 -2
  29. package/build/tab/save.cjs +2 -4
  30. package/build/tab/save.cjs.map +2 -2
  31. package/build/tabs/save.cjs +2 -4
  32. package/build/tabs/save.cjs.map +2 -2
  33. package/build/utils/media-control.cjs +1 -1
  34. package/build/utils/media-control.cjs.map +2 -2
  35. package/build-module/form-input/edit.mjs +36 -29
  36. package/build-module/form-input/edit.mjs.map +2 -2
  37. package/build-module/form-input/variations.mjs +10 -0
  38. package/build-module/form-input/variations.mjs.map +2 -2
  39. package/build-module/group/block.json +3 -1
  40. package/build-module/html/modal.mjs +151 -229
  41. package/build-module/html/modal.mjs.map +2 -2
  42. package/build-module/image/image.mjs +13 -4
  43. package/build-module/image/image.mjs.map +2 -2
  44. package/build-module/latest-comments/deprecated.mjs +33 -0
  45. package/build-module/latest-comments/deprecated.mjs.map +2 -2
  46. package/build-module/list-item/block.json +1 -0
  47. package/build-module/navigation/edit/index.mjs +123 -119
  48. package/build-module/navigation/edit/index.mjs.map +2 -2
  49. package/build-module/navigation/edit/navigation-menu-selector.mjs +2 -1
  50. package/build-module/navigation/edit/navigation-menu-selector.mjs.map +2 -2
  51. package/build-module/post-date/block.json +1 -3
  52. package/build-module/post-date/deprecated.mjs +82 -6
  53. package/build-module/post-date/deprecated.mjs.map +2 -2
  54. package/build-module/post-date/edit.mjs +49 -63
  55. package/build-module/post-date/edit.mjs.map +2 -2
  56. package/build-module/site-logo/edit.mjs +21 -14
  57. package/build-module/site-logo/edit.mjs.map +2 -2
  58. package/build-module/site-tagline/deprecated.mjs +2 -1
  59. package/build-module/site-tagline/deprecated.mjs.map +2 -2
  60. package/build-module/site-title/index.mjs +5 -1
  61. package/build-module/site-title/index.mjs.map +2 -2
  62. package/build-module/tab/save.mjs +2 -4
  63. package/build-module/tab/save.mjs.map +2 -2
  64. package/build-module/tabs/save.mjs +2 -4
  65. package/build-module/tabs/save.mjs.map +2 -2
  66. package/build-module/utils/media-control.mjs +1 -1
  67. package/build-module/utils/media-control.mjs.map +2 -2
  68. package/build-style/editor-rtl.css +15 -5
  69. package/build-style/editor.css +15 -5
  70. package/build-style/form-input/editor-rtl.css +6 -5
  71. package/build-style/form-input/editor.css +6 -5
  72. package/build-style/icon/editor-rtl.css +5 -0
  73. package/build-style/icon/editor.css +5 -0
  74. package/build-style/image/editor-rtl.css +4 -0
  75. package/build-style/image/editor.css +4 -0
  76. package/build-style/navigation/style-rtl.css +4 -1
  77. package/build-style/navigation/style.css +4 -1
  78. package/build-style/style-rtl.css +4 -1
  79. package/build-style/style.css +4 -1
  80. package/package.json +38 -38
  81. package/src/form-input/edit.js +19 -15
  82. package/src/form-input/editor.scss +6 -6
  83. package/src/form-input/variations.js +10 -0
  84. package/src/group/block.json +3 -1
  85. package/src/home-link/index.php +14 -33
  86. package/src/html/modal.js +6 -77
  87. package/src/icon/editor.scss +5 -0
  88. package/src/image/editor.scss +5 -0
  89. package/src/image/image.js +18 -3
  90. package/src/latest-comments/deprecated.js +33 -0
  91. package/src/list-item/block.json +1 -0
  92. package/src/loginout/index.php +13 -0
  93. package/src/navigation/edit/index.js +134 -130
  94. package/src/navigation/edit/navigation-menu-selector.js +2 -1
  95. package/src/navigation/index.php +24 -6
  96. package/src/navigation/style.scss +5 -3
  97. package/src/navigation-link/index.php +10 -38
  98. package/src/navigation-link/shared/build-css-font-sizes.php +43 -0
  99. package/src/navigation-submenu/index.php +10 -38
  100. package/src/page-list/index.php +14 -41
  101. package/src/post-date/block.json +1 -3
  102. package/src/post-date/deprecated.js +86 -6
  103. package/src/post-date/edit.js +65 -82
  104. package/src/site-logo/edit.js +24 -13
  105. package/src/site-tagline/deprecated.js +1 -0
  106. package/src/site-title/index.js +5 -1
  107. package/src/tab/save.js +2 -6
  108. package/src/tabs/save.js +2 -6
  109. 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( () => {
@@ -697,14 +697,10 @@ class WP_Navigation_Block_Renderer {
697
697
  if ( ! empty( $attributes['overlay'] ) ) {
698
698
  // Get blocks from the overlay template part.
699
699
  $overlay_blocks = static::get_overlay_blocks_from_template_part( $attributes['overlay'], $attributes );
700
- // Check if overlay contains a navigation-overlay-close block.
701
- $has_custom_overlay_close_block = block_core_navigation_block_tree_has_block_type(
702
- $overlay_blocks,
703
- 'core/navigation-overlay-close',
704
- array( 'core/navigation' ) // Skip navigation blocks, as they cannot contain an overlay close block
705
- );
706
700
  // Render template part blocks directly without navigation container wrapper.
707
701
  $overlay_blocks_html = static::get_template_part_blocks_html( $overlay_blocks );
702
+ // Check if overlay contains a navigation-overlay-close block (detect in rendered HTML so it works with patterns).
703
+ $has_custom_overlay_close_block = block_core_navigation_overlay_html_has_close_block( $overlay_blocks_html );
708
704
  // Add Interactivity API directives to the overlay close block if present.
709
705
  if ( $has_custom_overlay_close_block && $is_interactive ) {
710
706
  $tags = new WP_HTML_Tag_Processor( $overlay_blocks_html );
@@ -1094,6 +1090,28 @@ if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
1094
1090
  }
1095
1091
  }
1096
1092
 
1093
+ /**
1094
+ * Checks if the overlay HTML contains a navigation-overlay-close block.
1095
+ *
1096
+ * Uses WP_HTML_Tag_Processor to detect the close button in rendered output,
1097
+ * so it works when the overlay uses patterns (pattern content is rendered at
1098
+ * output time, not in the block tree).
1099
+ *
1100
+ * @since 7.0.0
1101
+ *
1102
+ * @param string $html The rendered overlay HTML.
1103
+ * @return bool True if a close button element is found.
1104
+ */
1105
+ function block_core_navigation_overlay_html_has_close_block( $html ) {
1106
+ $tags = new WP_HTML_Tag_Processor( $html );
1107
+ return $tags->next_tag(
1108
+ array(
1109
+ 'tag_name' => 'BUTTON',
1110
+ 'class_name' => 'wp-block-navigation-overlay-close',
1111
+ )
1112
+ );
1113
+ }
1114
+
1097
1115
  /**
1098
1116
  * Add Interactivity API directives to the navigation-overlay-close block
1099
1117
  * markup using the Tag Processor.
@@ -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
 
@@ -11,9 +11,6 @@
11
11
  "type": "string",
12
12
  "role": "content"
13
13
  },
14
- "textAlign": {
15
- "type": "string"
16
- },
17
14
  "format": {
18
15
  "type": "string"
19
16
  },
@@ -46,6 +43,7 @@
46
43
  "typography": {
47
44
  "fontSize": true,
48
45
  "lineHeight": true,
46
+ "textAlign": true,
49
47
  "__experimentalFontFamily": true,
50
48
  "__experimentalFontWeight": true,
51
49
  "__experimentalFontStyle": true,