@wordpress/block-library 9.40.1 → 9.40.2-next.v.202602271551.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 (208) hide show
  1. package/build/accordion/view.cjs +0 -34
  2. package/build/accordion/view.cjs.map +2 -2
  3. package/build/icon/block.json +9 -1
  4. package/build/icon/components/custom-inserter/icon-grid.cjs +1 -1
  5. package/build/icon/components/custom-inserter/icon-grid.cjs.map +2 -2
  6. package/build/icon/components/custom-inserter/index.cjs +1 -1
  7. package/build/icon/components/custom-inserter/index.cjs.map +2 -2
  8. package/build/icon/edit.cjs +15 -7
  9. package/build/icon/edit.cjs.map +2 -2
  10. package/build/image/edit.cjs +1 -1
  11. package/build/image/edit.cjs.map +2 -2
  12. package/build/navigation/edit/index.cjs +4 -2
  13. package/build/navigation/edit/index.cjs.map +3 -3
  14. package/build/navigation/edit/leaf-more-menu.cjs +68 -6
  15. package/build/navigation/edit/leaf-more-menu.cjs.map +3 -3
  16. package/build/navigation/edit/menu-inspector-controls.cjs +20 -91
  17. package/build/navigation/edit/menu-inspector-controls.cjs.map +3 -3
  18. package/build/navigation/edit/navigation-link-ui.cjs +97 -0
  19. package/build/navigation/edit/navigation-link-ui.cjs.map +7 -0
  20. package/build/navigation/edit/navigation-list-view-header.cjs +86 -0
  21. package/build/navigation/edit/navigation-list-view-header.cjs.map +7 -0
  22. package/build/navigation/edit/navigation-menu-selector.cjs +4 -2
  23. package/build/navigation/edit/navigation-menu-selector.cjs.map +3 -3
  24. package/build/navigation/edit/placeholder/index.cjs +2 -2
  25. package/build/navigation/edit/placeholder/index.cjs.map +3 -3
  26. package/build/navigation-link/shared/controls.cjs +29 -52
  27. package/build/navigation-link/shared/controls.cjs.map +3 -3
  28. package/build/navigation-link/shared/use-link-preview.cjs +7 -8
  29. package/build/navigation-link/shared/use-link-preview.cjs.map +2 -2
  30. package/build/navigation-overlay-close/edit.cjs +2 -3
  31. package/build/navigation-overlay-close/edit.cjs.map +2 -2
  32. package/build/page-list-item/edit.cjs +6 -3
  33. package/build/page-list-item/edit.cjs.map +2 -2
  34. package/build/post-navigation-link/block.json +1 -3
  35. package/build/post-navigation-link/deprecated.cjs +100 -0
  36. package/build/post-navigation-link/deprecated.cjs.map +7 -0
  37. package/build/post-navigation-link/edit.cjs +2 -36
  38. package/build/post-navigation-link/edit.cjs.map +3 -3
  39. package/build/post-navigation-link/index.cjs +2 -0
  40. package/build/post-navigation-link/index.cjs.map +3 -3
  41. package/build/post-title/block.json +1 -3
  42. package/build/post-title/deprecated.cjs +82 -1
  43. package/build/post-title/deprecated.cjs.map +3 -3
  44. package/build/post-title/edit.cjs +10 -36
  45. package/build/post-title/edit.cjs.map +3 -3
  46. package/build/pullquote/deprecated.cjs +6 -6
  47. package/build/pullquote/deprecated.cjs.map +2 -2
  48. package/build/query/block.json +1 -2
  49. package/build/query-title/block.json +1 -3
  50. package/build/query-title/deprecated.cjs +70 -1
  51. package/build/query-title/deprecated.cjs.map +3 -3
  52. package/build/query-title/edit.cjs +17 -35
  53. package/build/query-title/edit.cjs.map +3 -3
  54. package/build/site-tagline/block.json +6 -4
  55. package/build/site-tagline/deprecated.cjs +66 -1
  56. package/build/site-tagline/deprecated.cjs.map +3 -3
  57. package/build/site-tagline/edit.cjs +14 -28
  58. package/build/site-tagline/edit.cjs.map +3 -3
  59. package/build/site-title/block.json +1 -3
  60. package/build/site-title/deprecated.cjs +79 -1
  61. package/build/site-title/deprecated.cjs.map +3 -3
  62. package/build/site-title/edit.cjs +14 -30
  63. package/build/site-title/edit.cjs.map +3 -3
  64. package/build/tabs-menu-item/block.json +1 -26
  65. package/build/tabs-menu-item/controls.cjs +2 -100
  66. package/build/tabs-menu-item/controls.cjs.map +3 -3
  67. package/build/tabs-menu-item/edit.cjs +6 -65
  68. package/build/tabs-menu-item/edit.cjs.map +2 -2
  69. package/build/tabs-menu-item/save.cjs +1 -15
  70. package/build/tabs-menu-item/save.cjs.map +2 -2
  71. package/build-module/accordion/view.mjs +1 -35
  72. package/build-module/accordion/view.mjs.map +2 -2
  73. package/build-module/icon/block.json +9 -1
  74. package/build-module/icon/components/custom-inserter/icon-grid.mjs +1 -1
  75. package/build-module/icon/components/custom-inserter/icon-grid.mjs.map +2 -2
  76. package/build-module/icon/components/custom-inserter/index.mjs +1 -1
  77. package/build-module/icon/components/custom-inserter/index.mjs.map +2 -2
  78. package/build-module/icon/edit.mjs +15 -7
  79. package/build-module/icon/edit.mjs.map +2 -2
  80. package/build-module/image/edit.mjs +1 -1
  81. package/build-module/image/edit.mjs.map +2 -2
  82. package/build-module/navigation/edit/index.mjs +4 -2
  83. package/build-module/navigation/edit/index.mjs.map +2 -2
  84. package/build-module/navigation/edit/leaf-more-menu.mjs +73 -7
  85. package/build-module/navigation/edit/leaf-more-menu.mjs.map +2 -2
  86. package/build-module/navigation/edit/menu-inspector-controls.mjs +21 -101
  87. package/build-module/navigation/edit/menu-inspector-controls.mjs.map +2 -2
  88. package/build-module/navigation/edit/navigation-link-ui.mjs +76 -0
  89. package/build-module/navigation/edit/navigation-link-ui.mjs.map +7 -0
  90. package/build-module/navigation/edit/navigation-list-view-header.mjs +58 -0
  91. package/build-module/navigation/edit/navigation-list-view-header.mjs.map +7 -0
  92. package/build-module/navigation/edit/navigation-menu-selector.mjs +5 -3
  93. package/build-module/navigation/edit/navigation-menu-selector.mjs.map +2 -2
  94. package/build-module/navigation/edit/placeholder/index.mjs +2 -2
  95. package/build-module/navigation/edit/placeholder/index.mjs.map +2 -2
  96. package/build-module/navigation-link/shared/controls.mjs +29 -53
  97. package/build-module/navigation-link/shared/controls.mjs.map +2 -2
  98. package/build-module/navigation-link/shared/use-link-preview.mjs +7 -8
  99. package/build-module/navigation-link/shared/use-link-preview.mjs.map +2 -2
  100. package/build-module/navigation-overlay-close/edit.mjs +2 -3
  101. package/build-module/navigation-overlay-close/edit.mjs.map +2 -2
  102. package/build-module/page-list-item/edit.mjs +6 -3
  103. package/build-module/page-list-item/edit.mjs.map +2 -2
  104. package/build-module/post-navigation-link/block.json +1 -3
  105. package/build-module/post-navigation-link/deprecated.mjs +69 -0
  106. package/build-module/post-navigation-link/deprecated.mjs.map +7 -0
  107. package/build-module/post-navigation-link/edit.mjs +3 -30
  108. package/build-module/post-navigation-link/edit.mjs.map +2 -2
  109. package/build-module/post-navigation-link/index.mjs +2 -0
  110. package/build-module/post-navigation-link/index.mjs.map +2 -2
  111. package/build-module/post-title/block.json +1 -3
  112. package/build-module/post-title/deprecated.mjs +82 -1
  113. package/build-module/post-title/deprecated.mjs.map +2 -2
  114. package/build-module/post-title/edit.mjs +10 -27
  115. package/build-module/post-title/edit.mjs.map +2 -2
  116. package/build-module/pullquote/deprecated.mjs +6 -6
  117. package/build-module/pullquote/deprecated.mjs.map +2 -2
  118. package/build-module/query/block.json +1 -2
  119. package/build-module/query-title/block.json +1 -3
  120. package/build-module/query-title/deprecated.mjs +70 -1
  121. package/build-module/query-title/deprecated.mjs.map +2 -2
  122. package/build-module/query-title/edit.mjs +17 -36
  123. package/build-module/query-title/edit.mjs.map +2 -2
  124. package/build-module/site-tagline/block.json +6 -4
  125. package/build-module/site-tagline/deprecated.mjs +66 -1
  126. package/build-module/site-tagline/deprecated.mjs.map +2 -2
  127. package/build-module/site-tagline/edit.mjs +14 -29
  128. package/build-module/site-tagline/edit.mjs.map +2 -2
  129. package/build-module/site-title/block.json +1 -3
  130. package/build-module/site-title/deprecated.mjs +79 -1
  131. package/build-module/site-title/deprecated.mjs.map +2 -2
  132. package/build-module/site-title/edit.mjs +14 -31
  133. package/build-module/site-title/edit.mjs.map +2 -2
  134. package/build-module/tabs-menu-item/block.json +1 -26
  135. package/build-module/tabs-menu-item/controls.mjs +3 -104
  136. package/build-module/tabs-menu-item/controls.mjs.map +2 -2
  137. package/build-module/tabs-menu-item/edit.mjs +6 -66
  138. package/build-module/tabs-menu-item/edit.mjs.map +2 -2
  139. package/build-module/tabs-menu-item/save.mjs +1 -15
  140. package/build-module/tabs-menu-item/save.mjs.map +2 -2
  141. package/build-style/editor-rtl.css +10 -5
  142. package/build-style/editor.css +10 -5
  143. package/build-style/navigation-link/editor-rtl.css +10 -0
  144. package/build-style/navigation-link/editor.css +10 -0
  145. package/build-style/style-rtl.css +3 -12
  146. package/build-style/style.css +3 -12
  147. package/build-style/tabs-menu-item/editor-rtl.css +0 -5
  148. package/build-style/tabs-menu-item/editor.css +0 -5
  149. package/build-style/tabs-menu-item/style-rtl.css +3 -12
  150. package/build-style/tabs-menu-item/style.css +3 -12
  151. package/package.json +38 -38
  152. package/src/accordion/view.js +1 -44
  153. package/src/accordion-item/index.php +0 -1
  154. package/src/cover/index.php +4 -4
  155. package/src/icon/block.json +9 -1
  156. package/src/icon/components/custom-inserter/icon-grid.js +1 -1
  157. package/src/icon/components/custom-inserter/index.js +1 -1
  158. package/src/icon/edit.js +20 -10
  159. package/src/icon/index.php +1 -3
  160. package/src/image/edit.js +1 -1
  161. package/src/image/index.php +1 -4
  162. package/src/navigation/edit/index.js +4 -2
  163. package/src/navigation/edit/leaf-more-menu.js +86 -11
  164. package/src/navigation/edit/menu-inspector-controls.js +23 -142
  165. package/src/navigation/edit/navigation-link-ui.js +115 -0
  166. package/src/navigation/edit/navigation-list-view-header.js +62 -0
  167. package/src/navigation/edit/navigation-menu-selector.js +5 -3
  168. package/src/navigation/edit/placeholder/index.js +3 -2
  169. package/src/navigation/edit/test/navigation-menu-selector.js +23 -20
  170. package/src/navigation-link/editor.scss +18 -0
  171. package/src/navigation-link/shared/controls.js +35 -62
  172. package/src/navigation-link/shared/test/controls.js +5 -5
  173. package/src/navigation-link/shared/test/use-link-preview.test.js +10 -1
  174. package/src/navigation-link/shared/use-link-preview.js +13 -11
  175. package/src/navigation-overlay-close/edit.js +4 -3
  176. package/src/page-list/index.php +1 -1
  177. package/src/page-list-item/edit.js +8 -7
  178. package/src/post-featured-image/index.php +2 -4
  179. package/src/post-navigation-link/block.json +1 -3
  180. package/src/post-navigation-link/deprecated.js +72 -0
  181. package/src/post-navigation-link/edit.js +2 -35
  182. package/src/post-navigation-link/index.js +2 -0
  183. package/src/post-title/block.json +1 -3
  184. package/src/post-title/deprecated.js +86 -1
  185. package/src/post-title/edit.js +2 -18
  186. package/src/pullquote/deprecated.js +3 -3
  187. package/src/query/block.json +1 -2
  188. package/src/query-title/block.json +1 -3
  189. package/src/query-title/deprecated.js +74 -1
  190. package/src/query-title/edit.js +11 -27
  191. package/src/query-title/index.php +1 -1
  192. package/src/site-tagline/block.json +6 -4
  193. package/src/site-tagline/deprecated.js +70 -1
  194. package/src/site-tagline/edit.js +9 -22
  195. package/src/site-title/block.json +1 -3
  196. package/src/site-title/deprecated.js +83 -1
  197. package/src/site-title/edit.js +9 -22
  198. package/src/tabs-menu-item/block.json +1 -26
  199. package/src/tabs-menu-item/controls.js +0 -108
  200. package/src/tabs-menu-item/edit.js +6 -79
  201. package/src/tabs-menu-item/editor.scss +0 -6
  202. package/src/tabs-menu-item/save.js +1 -26
  203. package/src/tabs-menu-item/style.scss +3 -14
  204. package/build/navigation/use-navigation-entities.cjs +0 -67
  205. package/build/navigation/use-navigation-entities.cjs.map +0 -7
  206. package/build-module/navigation/use-navigation-entities.mjs +0 -46
  207. package/build-module/navigation/use-navigation-entities.mjs.map +0 -7
  208. package/src/navigation/use-navigation-entities.js +0 -72
@@ -237,7 +237,7 @@ describe( 'Controls', () => {
237
237
 
238
238
  render( <Controls { ...propsWithExternalLink } /> );
239
239
 
240
- expect( screen.getByText( 'View link' ) ).toBeVisible();
240
+ expect( screen.getByText( 'View' ) ).toBeVisible();
241
241
  } );
242
242
 
243
243
  it( 'shows "View page" for page links', () => {
@@ -253,7 +253,7 @@ describe( 'Controls', () => {
253
253
 
254
254
  render( <Controls { ...propsWithPageLink } /> );
255
255
 
256
- expect( screen.getByText( 'View page' ) ).toBeVisible();
256
+ expect( screen.getByText( 'View' ) ).toBeVisible();
257
257
  } );
258
258
 
259
259
  it( 'shows "View post" for post links', () => {
@@ -269,7 +269,7 @@ describe( 'Controls', () => {
269
269
 
270
270
  render( <Controls { ...propsWithPostLink } /> );
271
271
 
272
- expect( screen.getByText( 'View post' ) ).toBeVisible();
272
+ expect( screen.getByText( 'View' ) ).toBeVisible();
273
273
  } );
274
274
 
275
275
  it( 'shows "View category" for category links', () => {
@@ -285,7 +285,7 @@ describe( 'Controls', () => {
285
285
 
286
286
  render( <Controls { ...propsWithCategoryLink } /> );
287
287
 
288
- expect( screen.getByText( 'View category' ) ).toBeVisible();
288
+ expect( screen.getByText( 'View' ) ).toBeVisible();
289
289
  } );
290
290
 
291
291
  it( 'shows "View link" for custom type links', () => {
@@ -301,7 +301,7 @@ describe( 'Controls', () => {
301
301
 
302
302
  render( <Controls { ...propsWithCustomLink } /> );
303
303
 
304
- expect( screen.getByText( 'View link' ) ).toBeVisible();
304
+ expect( screen.getByText( 'View' ) ).toBeVisible();
305
305
  } );
306
306
  } );
307
307
  } );
@@ -92,10 +92,19 @@ describe( 'computeDisplayUrl', () => {
92
92
  it( 'should treat same-origin URLs as internal', () => {
93
93
  const result = computeDisplayUrl( {
94
94
  linkUrl: 'https://example.com/my-page',
95
- siteUrl: 'https://example.com',
95
+ homeUrl: 'https://example.com',
96
96
  } );
97
97
  expect( result.isExternal ).toBe( false );
98
98
  } );
99
+
100
+ it( 'should treat same-origin URLs as internal when homeUrl includes a path', () => {
101
+ const result = computeDisplayUrl( {
102
+ linkUrl: 'https://example.com/my-page',
103
+ homeUrl: 'https://example.com/blog',
104
+ } );
105
+ expect( result.isExternal ).toBe( false );
106
+ expect( result.displayUrl ).toBe( '/my-page' );
107
+ } );
99
108
  } );
100
109
 
101
110
  describe( 'special protocols and edge cases', () => {
@@ -31,10 +31,10 @@ function capitalize( str ) {
31
31
  *
32
32
  * @param {Object} options - Parameters object
33
33
  * @param {string} options.linkUrl - The URL to process
34
- * @param {string} options.siteUrl - The WordPress site URL (falls back to window.location.origin)
34
+ * @param {string} options.homeUrl - The WordPress site URL (falls back to window.location.origin)
35
35
  * @return {Object} Object with displayUrl and isExternal flag
36
36
  */
37
- export function computeDisplayUrl( { linkUrl, siteUrl } = {} ) {
37
+ export function computeDisplayUrl( { linkUrl, homeUrl } = {} ) {
38
38
  if ( ! linkUrl ) {
39
39
  return { displayUrl: '', isExternal: false };
40
40
  }
@@ -51,8 +51,11 @@ export function computeDisplayUrl( { linkUrl, siteUrl } = {} ) {
51
51
  // This must happen before trusting the type attribute
52
52
  try {
53
53
  const parsedUrl = new URL( linkUrl );
54
- // Use provided siteUrl or fall back to window.location.origin
55
- const siteDomain = siteUrl || window.location.origin;
54
+ // Use provided homeUrl or fall back to window.location.origin
55
+ const siteDomain = homeUrl
56
+ ? new URL( homeUrl ).origin
57
+ : window.location.origin;
58
+
56
59
  if ( parsedUrl.origin === siteDomain ) {
57
60
  // Show only the pathname (and search/hash if present)
58
61
  let path = parsedUrl.pathname + parsedUrl.search + parsedUrl.hash;
@@ -174,13 +177,12 @@ export function useLinkPreview( {
174
177
  hasBinding,
175
178
  isEntityAvailable,
176
179
  } ) {
177
- // Get the WordPress site URL from settings
178
- const siteUrl = useSelect( ( select ) => {
179
- const siteEntity = select( coreDataStore ).getEntityRecord(
180
+ // Get the WordPress homepage URL from settings
181
+ const homeUrl = useSelect( ( select ) => {
182
+ return select( coreDataStore ).getEntityRecord(
180
183
  'root',
181
- 'site'
182
- );
183
- return siteEntity?.url;
184
+ '__unstableBase'
185
+ )?.home;
184
186
  }, [] );
185
187
 
186
188
  const title =
@@ -194,7 +196,7 @@ export function useLinkPreview( {
194
196
  // Compute display URL and external flag
195
197
  const { displayUrl, isExternal } = computeDisplayUrl( {
196
198
  linkUrl: url,
197
- siteUrl,
199
+ homeUrl,
198
200
  } );
199
201
 
200
202
  const image = useSelect(
@@ -28,6 +28,9 @@ export default function NavigationOverlayCloseEdit( {
28
28
  const showIcon = displayMode === 'icon' || displayMode === 'both';
29
29
  const showText = displayMode === 'text' || displayMode === 'both';
30
30
 
31
+ // Use translated default if text is empty
32
+ const displayText = text || __( 'Close' );
33
+
31
34
  const blockProps = useBlockProps( {
32
35
  className: 'wp-block-navigation-overlay-close',
33
36
  } );
@@ -84,12 +87,10 @@ export default function NavigationOverlayCloseEdit( {
84
87
  { showText && (
85
88
  <RichText
86
89
  identifier="text"
87
- value={ text }
90
+ value={ displayText }
88
91
  onChange={ ( value ) =>
89
92
  setAttributes( { text: value } )
90
93
  }
91
- placeholder={ __( 'Close' ) }
92
- withoutInteractiveFormatting
93
94
  tagName="span"
94
95
  className="wp-block-navigation-overlay-close__text"
95
96
  allowedFormats={ [ 'core/bold', 'core/italic' ] }
@@ -166,7 +166,7 @@ function block_core_page_list_build_css_font_sizes( $context ) {
166
166
  *
167
167
  * @since 5.8.0
168
168
  *
169
- * @param boolean $open_submenus_on_click Whether to open submenus on click instead of hover.
169
+ * @param string $submenu_visibility The submenu visibility mode: 'hover', 'click', or 'always'.
170
170
  * @param boolean $show_submenu_icons Whether to show submenu indicator icons.
171
171
  * @param boolean $is_navigation_child If block is a child of Navigation block.
172
172
  * @param array $nested_pages The array of nested pages.
@@ -8,7 +8,6 @@ import clsx from 'clsx';
8
8
  import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
9
9
  import { useSelect } from '@wordpress/data';
10
10
  import { store as coreStore } from '@wordpress/core-data';
11
- import { RawHTML } from '@wordpress/element';
12
11
  import { safeHTML } from '@wordpress/dom';
13
12
 
14
13
  /**
@@ -78,9 +77,10 @@ export default function PageListItemEdit( { context, attributes } ) {
78
77
  type="button"
79
78
  className="wp-block-navigation-item__content wp-block-navigation-submenu__toggle"
80
79
  aria-expanded="false"
81
- >
82
- <RawHTML>{ safeHTML( label ) }</RawHTML>
83
- </button>
80
+ dangerouslySetInnerHTML={ {
81
+ __html: safeHTML( label ),
82
+ } }
83
+ />
84
84
  <span className="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon">
85
85
  <ItemSubmenuIcon />
86
86
  </span>
@@ -91,9 +91,10 @@ export default function PageListItemEdit( { context, attributes } ) {
91
91
  'wp-block-navigation-item__content': isNavigationChild,
92
92
  } ) }
93
93
  href={ link }
94
- >
95
- <RawHTML>{ safeHTML( title ) }</RawHTML>
96
- </a>
94
+ dangerouslySetInnerHTML={ {
95
+ __html: safeHTML( title ),
96
+ } }
97
+ />
97
98
  ) }
98
99
  { hasChildren && (
99
100
  <>
@@ -166,10 +166,8 @@ function get_block_core_post_featured_image_overlay_element_markup( $attributes
166
166
  }
167
167
 
168
168
  // Apply overlay and gradient classes.
169
- if ( $has_dim_background ) {
170
- $class_names[] = 'has-background-dim';
171
- $class_names[] = "has-background-dim-{$attributes['dimRatio']}";
172
- }
169
+ $class_names[] = 'has-background-dim';
170
+ $class_names[] = "has-background-dim-{$attributes['dimRatio']}";
173
171
 
174
172
  if ( $has_solid_overlay ) {
175
173
  $class_names[] = "has-{$attributes['overlayColor']}-background-color";
@@ -7,9 +7,6 @@
7
7
  "description": "Displays the next or previous post link that is adjacent to the current post.",
8
8
  "textdomain": "default",
9
9
  "attributes": {
10
- "textAlign": {
11
- "type": "string"
12
- },
13
10
  "type": {
14
11
  "type": "string",
15
12
  "default": "next"
@@ -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,
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import migrateTextAlign from '../utils/migrate-text-align';
5
+
6
+ const v1 = {
7
+ attributes: {
8
+ textAlign: {
9
+ type: 'string',
10
+ },
11
+ type: {
12
+ type: 'string',
13
+ default: 'next',
14
+ },
15
+ label: {
16
+ type: 'string',
17
+ role: 'content',
18
+ },
19
+ showTitle: {
20
+ type: 'boolean',
21
+ default: false,
22
+ },
23
+ linkLabel: {
24
+ type: 'boolean',
25
+ default: false,
26
+ },
27
+ arrow: {
28
+ type: 'string',
29
+ default: 'none',
30
+ },
31
+ taxonomy: {
32
+ type: 'string',
33
+ default: '',
34
+ },
35
+ },
36
+ supports: {
37
+ anchor: true,
38
+ reusable: false,
39
+ html: false,
40
+ color: {
41
+ link: true,
42
+ },
43
+ typography: {
44
+ fontSize: true,
45
+ lineHeight: true,
46
+ __experimentalFontFamily: true,
47
+ __experimentalFontWeight: true,
48
+ __experimentalFontStyle: true,
49
+ __experimentalTextTransform: true,
50
+ __experimentalTextDecoration: true,
51
+ __experimentalLetterSpacing: true,
52
+ __experimentalDefaultControls: {
53
+ fontSize: true,
54
+ },
55
+ },
56
+ interactivity: {
57
+ clientNavigation: true,
58
+ },
59
+ },
60
+ migrate: migrateTextAlign,
61
+ isEligible( attributes ) {
62
+ return (
63
+ !! attributes.textAlign ||
64
+ !! attributes.className?.match(
65
+ /\bhas-text-align-(left|center|right)\b/
66
+ )
67
+ );
68
+ },
69
+ save: () => null,
70
+ };
71
+
72
+ export default [ v1 ];
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import clsx from 'clsx';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -17,10 +12,7 @@ import {
17
12
  import {
18
13
  InspectorControls,
19
14
  RichText,
20
- BlockControls,
21
- AlignmentToolbar,
22
15
  useBlockProps,
23
- useBlockEditingMode,
24
16
  } from '@wordpress/block-editor';
25
17
  import { __, _x } from '@wordpress/i18n';
26
18
  import { useSelect } from '@wordpress/data';
@@ -33,19 +25,9 @@ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
33
25
 
34
26
  export default function PostNavigationLinkEdit( {
35
27
  context: { postType },
36
- attributes: {
37
- type,
38
- label,
39
- showTitle,
40
- textAlign,
41
- linkLabel,
42
- arrow,
43
- taxonomy,
44
- },
28
+ attributes: { type, label, showTitle, linkLabel, arrow, taxonomy },
45
29
  setAttributes,
46
30
  } ) {
47
- const blockEditingMode = useBlockEditingMode();
48
- const showControls = blockEditingMode === 'default';
49
31
  const isNext = type === 'next';
50
32
  let placeholder = isNext ? __( 'Next' ) : __( 'Previous' );
51
33
 
@@ -66,12 +48,7 @@ export default function PostNavigationLinkEdit( {
66
48
  }
67
49
 
68
50
  const ariaLabel = isNext ? __( 'Next post' ) : __( 'Previous post' );
69
- const blockProps = useBlockProps( {
70
- className: clsx( {
71
- [ `has-text-align-${ textAlign }` ]: textAlign,
72
- } ),
73
- } );
74
-
51
+ const blockProps = useBlockProps();
75
52
  const taxonomies = useSelect(
76
53
  ( select ) => {
77
54
  const { getTaxonomies } = select( coreStore );
@@ -220,16 +197,6 @@ export default function PostNavigationLinkEdit( {
220
197
  ) }
221
198
  />
222
199
  </InspectorControls>
223
- { showControls && (
224
- <BlockControls>
225
- <AlignmentToolbar
226
- value={ textAlign }
227
- onChange={ ( nextAlign ) => {
228
- setAttributes( { textAlign: nextAlign } );
229
- } }
230
- />
231
- </BlockControls>
232
- ) }
233
200
  <div { ...blockProps }>
234
201
  { ! isNext && displayArrow && (
235
202
  <span
@@ -10,6 +10,7 @@ import initBlock from '../utils/init-block';
10
10
  import metadata from './block.json';
11
11
  import edit from './edit';
12
12
  import variations from './variations';
13
+ import deprecated from './deprecated';
13
14
 
14
15
  const { name } = metadata;
15
16
  export { metadata, name };
@@ -17,6 +18,7 @@ export { metadata, name };
17
18
  export const settings = {
18
19
  edit,
19
20
  variations,
21
+ deprecated,
20
22
  example: {
21
23
  attributes: {
22
24
  label: __( 'Next post' ),
@@ -8,9 +8,6 @@
8
8
  "textdomain": "default",
9
9
  "usesContext": [ "postId", "postType", "queryId" ],
10
10
  "attributes": {
11
- "textAlign": {
12
- "type": "string"
13
- },
14
11
  "level": {
15
12
  "type": "number",
16
13
  "default": 2
@@ -58,6 +55,7 @@
58
55
  "typography": {
59
56
  "fontSize": true,
60
57
  "lineHeight": true,
58
+ "textAlign": true,
61
59
  "__experimentalFontFamily": true,
62
60
  "__experimentalFontWeight": true,
63
61
  "__experimentalFontStyle": true,
@@ -2,6 +2,91 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import migrateFontFamily from '../utils/migrate-font-family';
5
+ import migrateTextAlign from '../utils/migrate-text-align';
6
+
7
+ const v2 = {
8
+ attributes: {
9
+ textAlign: {
10
+ type: 'string',
11
+ },
12
+ level: {
13
+ type: 'number',
14
+ default: 2,
15
+ },
16
+ levelOptions: {
17
+ type: 'array',
18
+ },
19
+ isLink: {
20
+ type: 'boolean',
21
+ default: false,
22
+ },
23
+ rel: {
24
+ type: 'string',
25
+ attribute: 'rel',
26
+ default: '',
27
+ },
28
+ linkTarget: {
29
+ type: 'string',
30
+ default: '_self',
31
+ },
32
+ },
33
+ supports: {
34
+ anchor: true,
35
+ align: [ 'wide', 'full' ],
36
+ html: false,
37
+ color: {
38
+ gradients: true,
39
+ link: true,
40
+ __experimentalDefaultControls: {
41
+ background: true,
42
+ text: true,
43
+ link: true,
44
+ },
45
+ },
46
+ spacing: {
47
+ padding: true,
48
+ margin: true,
49
+ },
50
+ typography: {
51
+ fontSize: true,
52
+ lineHeight: true,
53
+ __experimentalFontFamily: true,
54
+ __experimentalTextTransform: true,
55
+ __experimentalTextDecoration: true,
56
+ __experimentalFontStyle: true,
57
+ __experimentalFontWeight: true,
58
+ __experimentalLetterSpacing: true,
59
+ __experimentalDefaultControls: {
60
+ fontSize: true,
61
+ },
62
+ },
63
+ interactivity: {
64
+ clientNavigation: true,
65
+ },
66
+ __experimentalBorder: {
67
+ radius: true,
68
+ color: true,
69
+ width: true,
70
+ style: true,
71
+ __experimentalDefaultControls: {
72
+ radius: true,
73
+ color: true,
74
+ width: true,
75
+ style: true,
76
+ },
77
+ },
78
+ },
79
+ migrate: migrateTextAlign,
80
+ isEligible( attributes ) {
81
+ return (
82
+ !! attributes.textAlign ||
83
+ !! attributes.className?.match(
84
+ /\bhas-text-align-(left|center|right)\b/
85
+ )
86
+ );
87
+ },
88
+ save: () => null,
89
+ };
5
90
 
6
91
  const v1 = {
7
92
  attributes: {
@@ -62,4 +147,4 @@ const v1 = {
62
147
  *
63
148
  * See block-deprecation.md
64
149
  */
65
- export default [ v1 ];
150
+ export default [ v2, v1 ];
@@ -1,13 +1,7 @@
1
- /**
2
- * External dependencies
3
- */
4
- import clsx from 'clsx';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
9
4
  import {
10
- AlignmentControl,
11
5
  BlockControls,
12
6
  InspectorControls,
13
7
  useBlockProps,
@@ -34,7 +28,7 @@ import { createInterpolateElement } from '@wordpress/element';
34
28
  import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
35
29
 
36
30
  export default function PostTitleEdit( {
37
- attributes: { level, levelOptions, textAlign, isLink, rel, linkTarget },
31
+ attributes: { level, levelOptions, isLink, rel, linkTarget },
38
32
  setAttributes,
39
33
  context: { postType, postId, queryId },
40
34
  insertBlocksAfter,
@@ -72,11 +66,7 @@ export default function PostTitleEdit( {
72
66
  const onSplitAtEnd = () => {
73
67
  insertBlocksAfter( createBlock( getDefaultBlockName() ) );
74
68
  };
75
- const blockProps = useBlockProps( {
76
- className: clsx( {
77
- [ `has-text-align-${ textAlign }` ]: textAlign,
78
- } ),
79
- } );
69
+ const blockProps = useBlockProps();
80
70
  const blockEditingMode = useBlockEditingMode();
81
71
  const dropdownMenuProps = useToolsPanelDropdownMenuProps();
82
72
 
@@ -147,12 +137,6 @@ export default function PostTitleEdit( {
147
137
  setAttributes( { level: newLevel } )
148
138
  }
149
139
  />
150
- <AlignmentControl
151
- value={ textAlign }
152
- onChange={ ( nextAlign ) => {
153
- setAttributes( { textAlign: nextAlign } );
154
- } }
155
- />
156
140
  </BlockControls>
157
141
  <InspectorControls>
158
142
  <ToolsPanel
@@ -297,8 +297,8 @@ const v4 = {
297
297
  backgroundColor: isSolidColorStyle ? mainColor : undefined,
298
298
  borderColor: isSolidColorStyle ? undefined : mainColor,
299
299
  textAlign: isSolidColorStyle ? 'left' : undefined,
300
- style,
301
300
  ...attributes,
301
+ style,
302
302
  };
303
303
  },
304
304
  };
@@ -454,8 +454,8 @@ const v3 = {
454
454
  backgroundColor: isSolidColorStyle ? mainColor : undefined,
455
455
  borderColor: isSolidColorStyle ? undefined : mainColor,
456
456
  textAlign: isSolidColorStyle ? 'left' : undefined,
457
- style,
458
457
  ...attributes,
458
+ style,
459
459
  };
460
460
  },
461
461
  };
@@ -572,8 +572,8 @@ const v2 = {
572
572
  backgroundColor: isSolidColorStyle ? mainColor : undefined,
573
573
  borderColor: isSolidColorStyle ? undefined : mainColor,
574
574
  textAlign: isSolidColorStyle ? 'left' : undefined,
575
- style,
576
575
  ...attributes,
576
+ style,
577
577
  };
578
578
  },
579
579
  };
@@ -54,8 +54,7 @@
54
54
  "align": [ "wide", "full" ],
55
55
  "html": false,
56
56
  "layout": true,
57
- "interactivity": true,
58
- "contentRole": true
57
+ "interactivity": true
59
58
  },
60
59
  "editorStyle": "wp-block-query-editor"
61
60
  }
@@ -10,9 +10,6 @@
10
10
  "type": {
11
11
  "type": "string"
12
12
  },
13
- "textAlign": {
14
- "type": "string"
15
- },
16
13
  "level": {
17
14
  "type": "number",
18
15
  "default": 1
@@ -53,6 +50,7 @@
53
50
  "typography": {
54
51
  "fontSize": true,
55
52
  "lineHeight": true,
53
+ "textAlign": true,
56
54
  "__experimentalFontFamily": true,
57
55
  "__experimentalFontStyle": true,
58
56
  "__experimentalFontWeight": true,
@@ -2,6 +2,79 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import migrateFontFamily from '../utils/migrate-font-family';
5
+ import migrateTextAlign from '../utils/migrate-text-align';
6
+
7
+ const v2 = {
8
+ attributes: {
9
+ type: {
10
+ type: 'string',
11
+ },
12
+ textAlign: {
13
+ type: 'string',
14
+ },
15
+ level: {
16
+ type: 'number',
17
+ default: 1,
18
+ },
19
+ levelOptions: {
20
+ type: 'array',
21
+ },
22
+ },
23
+ supports: {
24
+ anchor: true,
25
+ align: [ 'wide', 'full' ],
26
+ html: false,
27
+ color: {
28
+ gradients: true,
29
+ __experimentalDefaultControls: {
30
+ background: true,
31
+ text: true,
32
+ },
33
+ },
34
+ spacing: {
35
+ padding: true,
36
+ margin: true,
37
+ },
38
+ typography: {
39
+ fontSize: true,
40
+ lineHeight: true,
41
+ __experimentalFontFamily: true,
42
+ __experimentalTextTransform: true,
43
+ __experimentalTextDecoration: true,
44
+ __experimentalFontStyle: true,
45
+ __experimentalFontWeight: true,
46
+ __experimentalLetterSpacing: true,
47
+ __experimentalDefaultControls: {
48
+ fontSize: true,
49
+ },
50
+ },
51
+ interactivity: {
52
+ clientNavigation: true,
53
+ },
54
+ __experimentalBorder: {
55
+ radius: true,
56
+ color: true,
57
+ width: true,
58
+ style: true,
59
+ __experimentalDefaultControls: {
60
+ radius: true,
61
+ color: true,
62
+ width: true,
63
+ style: true,
64
+ },
65
+ },
66
+ },
67
+ migrate: migrateTextAlign,
68
+ isEligible( attributes ) {
69
+ return (
70
+ !! attributes.textAlign ||
71
+ !! attributes.className?.match(
72
+ /\bhas-text-align-(left|center|right)\b/
73
+ )
74
+ );
75
+ },
76
+ save: () => null,
77
+ };
5
78
 
6
79
  const v1 = {
7
80
  attributes: {
@@ -48,4 +121,4 @@ const v1 = {
48
121
  *
49
122
  * See block-deprecation.md
50
123
  */
51
- export default [ v1 ];
124
+ export default [ v2, v1 ];