@wordpress/block-library 7.14.1 → 7.15.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 (193) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/avatar/index.js +1 -1
  3. package/build/block/edit.native.js +1 -1
  4. package/build/block/edit.native.js.map +1 -1
  5. package/build/buttons/edit.native.js +1 -3
  6. package/build/buttons/edit.native.js.map +1 -1
  7. package/build/calendar/index.js +9 -0
  8. package/build/calendar/index.js.map +1 -1
  9. package/build/code/index.js +1 -1
  10. package/build/code/index.js.map +1 -1
  11. package/build/comments/edit/comments-legacy.js +1 -1
  12. package/build/comments/edit/comments-legacy.js.map +1 -1
  13. package/build/comments-pagination-next/index.js +1 -1
  14. package/build/comments-pagination-numbers/index.js +1 -1
  15. package/build/comments-pagination-previous/index.js +1 -1
  16. package/build/comments-title/edit.js +1 -1
  17. package/build/comments-title/edit.js.map +1 -1
  18. package/build/cover/edit/use-cover-is-dark.js +10 -7
  19. package/build/cover/edit/use-cover-is-dark.js.map +1 -1
  20. package/build/cover/index.js +9 -2
  21. package/build/cover/index.js.map +1 -1
  22. package/build/embed/deprecated.js +12 -6
  23. package/build/embed/deprecated.js.map +1 -1
  24. package/build/embed/index.js +12 -6
  25. package/build/embed/index.js.map +1 -1
  26. package/build/embed/transforms.js +12 -6
  27. package/build/embed/transforms.js.map +1 -1
  28. package/build/embed/util.js +12 -6
  29. package/build/embed/util.js.map +1 -1
  30. package/build/embed/variations.js +1 -1
  31. package/build/embed/variations.js.map +1 -1
  32. package/build/freeform/edit.js +5 -8
  33. package/build/freeform/edit.js.map +1 -1
  34. package/build/gallery/deprecated.js +4 -4
  35. package/build/gallery/deprecated.js.map +1 -1
  36. package/build/list-item/edit.js +2 -1
  37. package/build/list-item/edit.js.map +1 -1
  38. package/build/missing/edit.js +9 -2
  39. package/build/missing/edit.js.map +1 -1
  40. package/build/more/edit.js +1 -1
  41. package/build/more/edit.js.map +1 -1
  42. package/build/navigation/menu-items-to-blocks.js +16 -6
  43. package/build/navigation/menu-items-to-blocks.js.map +1 -1
  44. package/build/post-excerpt/edit.js +1 -1
  45. package/build/post-excerpt/edit.js.map +1 -1
  46. package/build/post-navigation-link/edit.js +35 -4
  47. package/build/post-navigation-link/edit.js.map +1 -1
  48. package/build/post-navigation-link/index.js +6 -1
  49. package/build/post-navigation-link/index.js.map +1 -1
  50. package/build/post-template/edit.js +13 -28
  51. package/build/post-template/edit.js.map +1 -1
  52. package/build/query/edit/inspector-controls/index.js +4 -8
  53. package/build/query/edit/inspector-controls/index.js.map +1 -1
  54. package/build/query/edit/inspector-controls/sticky-control.js +1 -1
  55. package/build/query/edit/inspector-controls/sticky-control.js.map +1 -1
  56. package/build/query/edit/query-placeholder.js +2 -2
  57. package/build/query/edit/query-placeholder.js.map +1 -1
  58. package/build/query-title/edit.js +1 -1
  59. package/build/query-title/edit.js.map +1 -1
  60. package/build/quote/transforms.js +2 -2
  61. package/build/quote/transforms.js.map +1 -1
  62. package/build/read-more/edit.js +1 -1
  63. package/build/read-more/edit.js.map +1 -1
  64. package/build/site-tagline/index.js +1 -1
  65. package/build/social-links/edit.native.js +1 -0
  66. package/build/social-links/edit.native.js.map +1 -1
  67. package/build/template-part/edit/index.js +2 -2
  68. package/build/template-part/edit/index.js.map +1 -1
  69. package/build-module/avatar/index.js +1 -1
  70. package/build-module/block/edit.native.js +1 -1
  71. package/build-module/block/edit.native.js.map +1 -1
  72. package/build-module/buttons/edit.native.js +1 -2
  73. package/build-module/buttons/edit.native.js.map +1 -1
  74. package/build-module/calendar/index.js +9 -0
  75. package/build-module/calendar/index.js.map +1 -1
  76. package/build-module/code/index.js +1 -1
  77. package/build-module/code/index.js.map +1 -1
  78. package/build-module/comments/edit/comments-legacy.js +1 -1
  79. package/build-module/comments/edit/comments-legacy.js.map +1 -1
  80. package/build-module/comments-pagination-next/index.js +1 -1
  81. package/build-module/comments-pagination-numbers/index.js +1 -1
  82. package/build-module/comments-pagination-previous/index.js +1 -1
  83. package/build-module/comments-title/edit.js +1 -1
  84. package/build-module/comments-title/edit.js.map +1 -1
  85. package/build-module/cover/edit/use-cover-is-dark.js +9 -4
  86. package/build-module/cover/edit/use-cover-is-dark.js.map +1 -1
  87. package/build-module/cover/index.js +9 -2
  88. package/build-module/cover/index.js.map +1 -1
  89. package/build-module/embed/deprecated.js +12 -6
  90. package/build-module/embed/deprecated.js.map +1 -1
  91. package/build-module/embed/index.js +12 -6
  92. package/build-module/embed/index.js.map +1 -1
  93. package/build-module/embed/transforms.js +12 -6
  94. package/build-module/embed/transforms.js.map +1 -1
  95. package/build-module/embed/util.js +12 -6
  96. package/build-module/embed/util.js.map +1 -1
  97. package/build-module/embed/variations.js +1 -1
  98. package/build-module/embed/variations.js.map +1 -1
  99. package/build-module/freeform/edit.js +3 -6
  100. package/build-module/freeform/edit.js.map +1 -1
  101. package/build-module/gallery/deprecated.js +4 -4
  102. package/build-module/gallery/deprecated.js.map +1 -1
  103. package/build-module/list-item/edit.js +2 -1
  104. package/build-module/list-item/edit.js.map +1 -1
  105. package/build-module/missing/edit.js +11 -4
  106. package/build-module/missing/edit.js.map +1 -1
  107. package/build-module/more/edit.js +1 -1
  108. package/build-module/more/edit.js.map +1 -1
  109. package/build-module/navigation/menu-items-to-blocks.js +16 -6
  110. package/build-module/navigation/menu-items-to-blocks.js.map +1 -1
  111. package/build-module/post-excerpt/edit.js +1 -1
  112. package/build-module/post-excerpt/edit.js.map +1 -1
  113. package/build-module/post-navigation-link/edit.js +37 -6
  114. package/build-module/post-navigation-link/edit.js.map +1 -1
  115. package/build-module/post-navigation-link/index.js +6 -1
  116. package/build-module/post-navigation-link/index.js.map +1 -1
  117. package/build-module/post-template/edit.js +14 -29
  118. package/build-module/post-template/edit.js.map +1 -1
  119. package/build-module/query/edit/inspector-controls/index.js +2 -6
  120. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  121. package/build-module/query/edit/inspector-controls/sticky-control.js +1 -1
  122. package/build-module/query/edit/inspector-controls/sticky-control.js.map +1 -1
  123. package/build-module/query/edit/query-placeholder.js +2 -2
  124. package/build-module/query/edit/query-placeholder.js.map +1 -1
  125. package/build-module/query-title/edit.js +1 -1
  126. package/build-module/query-title/edit.js.map +1 -1
  127. package/build-module/quote/transforms.js +2 -2
  128. package/build-module/quote/transforms.js.map +1 -1
  129. package/build-module/read-more/edit.js +1 -1
  130. package/build-module/read-more/edit.js.map +1 -1
  131. package/build-module/site-tagline/index.js +1 -1
  132. package/build-module/social-links/edit.native.js +1 -0
  133. package/build-module/social-links/edit.native.js.map +1 -1
  134. package/build-module/template-part/edit/index.js +3 -3
  135. package/build-module/template-part/edit/index.js.map +1 -1
  136. package/build-style/calendar/style-rtl.css +21 -12
  137. package/build-style/calendar/style.css +21 -12
  138. package/build-style/post-navigation-link/style-rtl.css +90 -0
  139. package/build-style/post-navigation-link/style.css +90 -0
  140. package/build-style/style-rtl.css +36 -12
  141. package/build-style/style.css +36 -12
  142. package/package.json +29 -29
  143. package/src/avatar/block.json +1 -1
  144. package/src/block/edit.native.js +1 -1
  145. package/src/buttons/edit.native.js +1 -2
  146. package/src/buttons/test/__snapshots__/edit.native.js.snap +28 -0
  147. package/src/buttons/test/edit.native.js +170 -0
  148. package/src/calendar/block.json +9 -0
  149. package/src/calendar/index.php +22 -1
  150. package/src/calendar/style.scss +28 -15
  151. package/src/code/index.js +1 -1
  152. package/src/columns/test/__snapshots__/edit.native.js.snap +219 -0
  153. package/src/columns/test/edit.native.js +432 -0
  154. package/src/comments/edit/comments-legacy.js +1 -1
  155. package/src/comments-pagination-next/block.json +1 -1
  156. package/src/comments-pagination-numbers/block.json +1 -1
  157. package/src/comments-pagination-previous/block.json +1 -1
  158. package/src/comments-title/edit.js +1 -1
  159. package/src/cover/edit/use-cover-is-dark.js +11 -7
  160. package/src/cover/index.js +8 -1
  161. package/src/cover/test/__snapshots__/edit.native.js.snap +64 -0
  162. package/src/cover/test/edit.native.js +136 -4
  163. package/src/embed/block.json +12 -6
  164. package/src/embed/test/index.native.js +1 -2
  165. package/src/embed/variations.js +1 -1
  166. package/src/freeform/edit.js +12 -10
  167. package/src/gallery/deprecated.js +4 -4
  168. package/src/group/test/__snapshots__/edit.native.js.snap +19 -0
  169. package/src/group/test/edit.native.js +102 -0
  170. package/src/list-item/edit.js +1 -0
  171. package/src/missing/edit.js +15 -4
  172. package/src/more/edit.js +1 -1
  173. package/src/navigation/menu-items-to-blocks.js +39 -22
  174. package/src/navigation/test/menu-items-to-blocks.js +6 -0
  175. package/src/post-excerpt/edit.js +1 -1
  176. package/src/post-featured-image/index.php +11 -18
  177. package/src/post-navigation-link/block.json +6 -1
  178. package/src/post-navigation-link/edit.js +64 -3
  179. package/src/post-navigation-link/index.php +23 -0
  180. package/src/post-navigation-link/style.scss +23 -0
  181. package/src/post-template/edit.js +14 -23
  182. package/src/query/edit/inspector-controls/index.js +2 -6
  183. package/src/query/edit/inspector-controls/sticky-control.js +1 -1
  184. package/src/query/edit/query-placeholder.js +4 -1
  185. package/src/query-title/edit.js +1 -1
  186. package/src/quote/transforms.js +1 -1
  187. package/src/read-more/edit.js +1 -1
  188. package/src/site-tagline/block.json +1 -1
  189. package/src/social-links/edit.native.js +7 -1
  190. package/src/social-links/test/__snapshots__/edit.native.js.snap +57 -0
  191. package/src/social-links/test/edit.native.js +199 -0
  192. package/src/style.scss +1 -0
  193. package/src/template-part/edit/index.js +60 -58
@@ -29,9 +29,10 @@ export default function menuItemsToBlocks( menuItems ) {
29
29
  * A recursive function that maps menu item nodes to blocks.
30
30
  *
31
31
  * @param {WPNavMenuItem[]} menuItems An array of WPNavMenuItem items.
32
+ * @param {number} level An integer representing the nesting level.
32
33
  * @return {Object} Object containing innerBlocks and mapping.
33
34
  */
34
- function mapMenuItemsToBlocks( menuItems ) {
35
+ function mapMenuItemsToBlocks( menuItems, level = 0 ) {
35
36
  let mapping = {};
36
37
 
37
38
  // The menuItem should be in menu_order sort order.
@@ -52,14 +53,22 @@ function mapMenuItemsToBlocks( menuItems ) {
52
53
  return block;
53
54
  }
54
55
 
55
- const attributes = menuItemToBlockAttributes( menuItem );
56
+ const blockType = menuItem.children?.length
57
+ ? 'core/navigation-submenu'
58
+ : 'core/navigation-link';
59
+
60
+ const attributes = menuItemToBlockAttributes(
61
+ menuItem,
62
+ blockType,
63
+ level
64
+ );
56
65
 
57
66
  // If there are children recurse to build those nested blocks.
58
67
  const {
59
68
  innerBlocks: nestedBlocks = [], // alias to avoid shadowing
60
69
  mapping: nestedMapping = {}, // alias to avoid shadowing
61
70
  } = menuItem.children?.length
62
- ? mapMenuItemsToBlocks( menuItem.children )
71
+ ? mapMenuItemsToBlocks( menuItem.children, level + 1 )
63
72
  : {};
64
73
 
65
74
  // Update parent mapping with nested mapping.
@@ -68,10 +77,6 @@ function mapMenuItemsToBlocks( menuItems ) {
68
77
  ...nestedMapping,
69
78
  };
70
79
 
71
- const blockType = menuItem.children?.length
72
- ? 'core/navigation-submenu'
73
- : 'core/navigation-link';
74
-
75
80
  // Create block with nested "innerBlocks".
76
81
  const block = createBlock( blockType, attributes, nestedBlocks );
77
82
 
@@ -111,23 +116,29 @@ function mapMenuItemsToBlocks( menuItems ) {
111
116
  /**
112
117
  * Convert block attributes to menu item.
113
118
  *
114
- * @param {WPNavMenuItem} menuItem the menu item to be converted to block attributes.
119
+ * @param {WPNavMenuItem} menuItem the menu item to be converted to block attributes.
120
+ * @param {string} blockType The block type.
121
+ * @param {number} level An integer representing the nesting level.
115
122
  * @return {Object} the block attributes converted from the WPNavMenuItem item.
116
123
  */
117
- function menuItemToBlockAttributes( {
118
- title: menuItemTitleField,
119
- xfn,
120
- classes,
121
- // eslint-disable-next-line camelcase
122
- attr_title,
123
- object,
124
- // eslint-disable-next-line camelcase
125
- object_id,
126
- description,
127
- url,
128
- type: menuItemTypeField,
129
- target,
130
- } ) {
124
+ function menuItemToBlockAttributes(
125
+ {
126
+ title: menuItemTitleField,
127
+ xfn,
128
+ classes,
129
+ // eslint-disable-next-line camelcase
130
+ attr_title,
131
+ object,
132
+ // eslint-disable-next-line camelcase
133
+ object_id,
134
+ description,
135
+ url,
136
+ type: menuItemTypeField,
137
+ target,
138
+ },
139
+ blockType,
140
+ level
141
+ ) {
131
142
  // For historical reasons, the `core/navigation-link` variation type is `tag`
132
143
  // whereas WP Core expects `post_tag` as the `object` type.
133
144
  // To avoid writing a block migration we perform a conversion here.
@@ -166,6 +177,12 @@ function menuItemToBlockAttributes( {
166
177
  ...( target === '_blank' && {
167
178
  opensInNewTab: true,
168
179
  } ),
180
+ ...( blockType === 'core/navigation-submenu' && {
181
+ isTopLevelItem: level === 0,
182
+ } ),
183
+ ...( blockType === 'core/navigation-link' && {
184
+ isTopLevelLink: level === 0,
185
+ } ),
169
186
  };
170
187
  }
171
188
 
@@ -189,12 +189,14 @@ describe( 'converting menu items to blocks', () => {
189
189
  name: 'core/navigation-submenu',
190
190
  attributes: expect.objectContaining( {
191
191
  label: 'Top Level',
192
+ isTopLevelItem: true,
192
193
  } ),
193
194
  innerBlocks: [
194
195
  expect.objectContaining( {
195
196
  name: 'core/navigation-link',
196
197
  attributes: expect.objectContaining( {
197
198
  label: 'Child 1',
199
+ isTopLevelLink: false,
198
200
  } ),
199
201
  innerBlocks: [],
200
202
  } ),
@@ -202,18 +204,21 @@ describe( 'converting menu items to blocks', () => {
202
204
  name: 'core/navigation-submenu',
203
205
  attributes: expect.objectContaining( {
204
206
  label: 'Child 2',
207
+ isTopLevelItem: false,
205
208
  } ),
206
209
  innerBlocks: [
207
210
  expect.objectContaining( {
208
211
  name: 'core/navigation-submenu',
209
212
  attributes: expect.objectContaining( {
210
213
  label: 'Sub Child',
214
+ isTopLevelItem: false,
211
215
  } ),
212
216
  innerBlocks: [
213
217
  expect.objectContaining( {
214
218
  name: 'core/navigation-link',
215
219
  attributes: expect.objectContaining( {
216
220
  label: 'Sub Sub Child',
221
+ isTopLevelLink: false,
217
222
  } ),
218
223
  innerBlocks: [],
219
224
  } ),
@@ -227,6 +232,7 @@ describe( 'converting menu items to blocks', () => {
227
232
  name: 'core/navigation-link',
228
233
  attributes: expect.objectContaining( {
229
234
  label: 'Top Level 2',
235
+ isTopLevelLink: true,
230
236
  } ),
231
237
  innerBlocks: [],
232
238
  } ),
@@ -87,7 +87,7 @@ export default function PostExcerptEditor( {
87
87
  <RichText
88
88
  className="wp-block-post-excerpt__more-link"
89
89
  tagName="a"
90
- aria-label={ __( '"Read more" link text' ) }
90
+ aria-label={ __( 'Read more link text' ) }
91
91
  placeholder={ __( 'Add "read more" link text' ) }
92
92
  value={ moreText }
93
93
  onChange={ ( newMoreText ) =>
@@ -29,11 +29,18 @@ function render_block_core_post_featured_image( $attributes, $content, $block )
29
29
  $attr['alt'] = $post_title;
30
30
  }
31
31
 
32
+ if ( ! empty( $attributes['height'] ) ) {
33
+ $extra_styles = "height:{$attributes['height']};";
34
+ if ( ! empty( $attributes['scale'] ) ) {
35
+ $extra_styles .= "object-fit:{$attributes['scale']};";
36
+ }
37
+ $attr['style'] = empty( $attr['style'] ) ? $extra_styles : $attr['style'] . $extra_styles;
38
+ }
39
+
32
40
  $featured_image = get_the_post_thumbnail( $post_ID, $size_slug, $attr );
33
41
  if ( ! $featured_image ) {
34
42
  return '';
35
43
  }
36
- $wrapper_attributes = get_block_wrapper_attributes();
37
44
  if ( $is_link ) {
38
45
  $link_target = $attributes['linkTarget'];
39
46
  $rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';
@@ -49,23 +56,9 @@ function render_block_core_post_featured_image( $attributes, $content, $block )
49
56
  $featured_image = $featured_image . $overlay_markup;
50
57
  }
51
58
 
52
- $has_width = ! empty( $attributes['width'] );
53
- $has_height = ! empty( $attributes['height'] );
54
- if ( ! $has_height && ! $has_width ) {
55
- return "<figure {$wrapper_attributes}>{$featured_image}</figure>";
56
- }
57
-
58
- if ( $has_width ) {
59
- $wrapper_attributes = get_block_wrapper_attributes( array( 'style' => "width:{$attributes['width']};" ) );
60
- }
61
-
62
- if ( $has_height ) {
63
- $image_styles = "height:{$attributes['height']};";
64
- if ( ! empty( $attributes['scale'] ) ) {
65
- $image_styles .= "object-fit:{$attributes['scale']};";
66
- }
67
- $featured_image = str_replace( 'src=', 'style="' . esc_attr( $image_styles ) . '" src=', $featured_image );
68
- }
59
+ $wrapper_attributes = empty( $attributes['width'] )
60
+ ? get_block_wrapper_attributes()
61
+ : get_block_wrapper_attributes( array( 'style' => "width:{$attributes['width']};" ) );
69
62
 
70
63
  return "<figure {$wrapper_attributes}>{$featured_image}</figure>";
71
64
  }
@@ -24,6 +24,10 @@
24
24
  "linkLabel": {
25
25
  "type": "boolean",
26
26
  "default": false
27
+ },
28
+ "arrow": {
29
+ "type": "string",
30
+ "default": "none"
27
31
  }
28
32
  },
29
33
  "supports": {
@@ -45,5 +49,6 @@
45
49
  "fontSize": true
46
50
  }
47
51
  }
48
- }
52
+ },
53
+ "style": "wp-block-post-navigation-link"
49
54
  }
@@ -6,7 +6,12 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { ToggleControl, PanelBody } from '@wordpress/components';
9
+ import {
10
+ __experimentalToggleGroupControl as ToggleGroupControl,
11
+ __experimentalToggleGroupControlOption as ToggleGroupControlOption,
12
+ ToggleControl,
13
+ PanelBody,
14
+ } from '@wordpress/components';
10
15
  import {
11
16
  InspectorControls,
12
17
  RichText,
@@ -14,15 +19,23 @@ import {
14
19
  AlignmentToolbar,
15
20
  useBlockProps,
16
21
  } from '@wordpress/block-editor';
17
- import { __ } from '@wordpress/i18n';
22
+ import { __, _x } from '@wordpress/i18n';
18
23
 
19
24
  export default function PostNavigationLinkEdit( {
20
- attributes: { type, label, showTitle, textAlign, linkLabel },
25
+ attributes: { type, label, showTitle, textAlign, linkLabel, arrow },
21
26
  setAttributes,
22
27
  } ) {
23
28
  const isNext = type === 'next';
24
29
  let placeholder = isNext ? __( 'Next' ) : __( 'Previous' );
25
30
 
31
+ const arrowMap = {
32
+ none: '',
33
+ arrow: isNext ? '→' : '←',
34
+ chevron: isNext ? '»' : '«',
35
+ };
36
+
37
+ const displayArrow = arrowMap[ arrow ];
38
+
26
39
  if ( showTitle ) {
27
40
  /* translators: Label before for next and previous post. There is a space after the colon. */
28
41
  placeholder = isNext ? __( 'Next: ' ) : __( 'Previous: ' );
@@ -63,6 +76,39 @@ export default function PostNavigationLinkEdit( {
63
76
  }
64
77
  />
65
78
  ) }
79
+ <ToggleGroupControl
80
+ label={ __( 'Arrow' ) }
81
+ value={ arrow }
82
+ onChange={ ( value ) => {
83
+ setAttributes( { arrow: value } );
84
+ } }
85
+ help={ __(
86
+ 'A decorative arrow for the next and previous link.'
87
+ ) }
88
+ isBlock
89
+ >
90
+ <ToggleGroupControlOption
91
+ value="none"
92
+ label={ _x(
93
+ 'None',
94
+ 'Arrow option for Next/Previous link'
95
+ ) }
96
+ />
97
+ <ToggleGroupControlOption
98
+ value="arrow"
99
+ label={ _x(
100
+ 'Arrow',
101
+ 'Arrow option for Next/Previous link'
102
+ ) }
103
+ />
104
+ <ToggleGroupControlOption
105
+ value="chevron"
106
+ label={ _x(
107
+ 'Chevron',
108
+ 'Arrow option for Next/Previous link'
109
+ ) }
110
+ />
111
+ </ToggleGroupControl>
66
112
  </PanelBody>
67
113
  </InspectorControls>
68
114
  <BlockControls>
@@ -74,6 +120,13 @@ export default function PostNavigationLinkEdit( {
74
120
  />
75
121
  </BlockControls>
76
122
  <div { ...blockProps }>
123
+ { ! isNext && displayArrow && (
124
+ <span
125
+ className={ `wp-block-post-navigation-link__arrow-previous is-arrow-${ arrow }` }
126
+ >
127
+ { displayArrow }
128
+ </span>
129
+ ) }
77
130
  <RichText
78
131
  tagName="a"
79
132
  aria-label={ ariaLabel }
@@ -92,6 +145,14 @@ export default function PostNavigationLinkEdit( {
92
145
  { __( 'An example title' ) }
93
146
  </a>
94
147
  ) }
148
+ { isNext && displayArrow && (
149
+ <span
150
+ className={ `wp-block-post-navigation-link__arrow-next is-arrow-${ arrow }` }
151
+ aria-hidden={ true }
152
+ >
153
+ { displayArrow }
154
+ </span>
155
+ ) }
95
156
  </div>
96
157
  </>
97
158
  );
@@ -34,6 +34,18 @@ function render_block_core_post_navigation_link( $attributes, $content ) {
34
34
  $link = 'next' === $navigation_type ? _x( 'Next', 'label for next post link' ) : _x( 'Previous', 'label for previous post link' );
35
35
  $label = '';
36
36
 
37
+ $arrow_map = array(
38
+ 'none' => '',
39
+ 'arrow' => array(
40
+ 'next' => '→',
41
+ 'previous' => '←',
42
+ ),
43
+ 'chevron' => array(
44
+ 'next' => '»',
45
+ 'previous' => '«',
46
+ ),
47
+ );
48
+
37
49
  // If a custom label is provided, make this a link.
38
50
  // `$label` is used to prepend the provided label, if we want to show the page title as well.
39
51
  if ( isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ) {
@@ -71,6 +83,17 @@ function render_block_core_post_navigation_link( $attributes, $content ) {
71
83
  }
72
84
  }
73
85
 
86
+ // Display arrows.
87
+ if ( isset( $attributes['arrow'] ) && ! empty( $attributes['arrow'] ) && 'none' !== $attributes['arrow'] ) {
88
+ $arrow = $arrow_map[ $attributes['arrow'] ][ $navigation_type ];
89
+
90
+ if ( 'next' === $navigation_type ) {
91
+ $format = '%link <span class="wp-block-post-navigation-link__arrow-next is-arrow-' . $attributes['arrow'] . '" aria-hidden="true">' . $arrow . '</span>';
92
+ } else {
93
+ $format = '<span class="wp-block-post-navigation-link__arrow-previous is-arrow-' . $attributes['arrow'] . '" aria-hidden="true">' . $arrow . '</span> %link';
94
+ }
95
+ }
96
+
74
97
  // The dynamic portion of the function name, `$navigation_type`,
75
98
  // refers to the type of adjacency, 'next' or 'previous'.
76
99
  $get_link_function = "get_{$navigation_type}_post_link";
@@ -0,0 +1,23 @@
1
+ .wp-block-post-navigation-link {
2
+
3
+ .wp-block-post-navigation-link__arrow-previous {
4
+ display: inline-block;
5
+ margin-right: 1ch;
6
+ // chevron(`»`) symbol doesn't need the mirroring by us.
7
+ &:not(.is-arrow-chevron) {
8
+ // Flip for RTL.
9
+ transform: scaleX(1) #{"/*rtl:scaleX(-1);*/"}; // This points the arrow right for LTR and left for RTL.
10
+ }
11
+ }
12
+
13
+ .wp-block-post-navigation-link__arrow-next {
14
+ display: inline-block;
15
+ margin-left: 1ch;
16
+ // chevron(`»`) symbol doesn't need the mirroring by us.
17
+ &:not(.is-arrow-chevron) {
18
+ // Flip for RTL.
19
+ transform: scaleX(1) #{"/*rtl:scaleX(-1);*/"}; // This points the arrow right for LTR and left for RTL.
20
+ }
21
+ }
22
+
23
+ }
@@ -17,7 +17,7 @@ import {
17
17
  store as blockEditorStore,
18
18
  } from '@wordpress/block-editor';
19
19
  import { Spinner } from '@wordpress/components';
20
- import { store as coreStore, useEntityRecords } from '@wordpress/core-data';
20
+ import { store as coreStore } from '@wordpress/core-data';
21
21
 
22
22
  const TEMPLATE = [
23
23
  [ 'core/post-title' ],
@@ -101,19 +101,6 @@ export default function PostTemplateEdit( {
101
101
  } ) {
102
102
  const [ { page } ] = queryContext;
103
103
  const [ activeBlockContextId, setActiveBlockContextId ] = useState();
104
-
105
- let categorySlug = null;
106
- if ( templateSlug?.startsWith( 'category-' ) ) {
107
- categorySlug = templateSlug.replace( 'category-', '' );
108
- }
109
- const { records: categories, hasResolved: hasResolvedCategories } =
110
- useEntityRecords( 'taxonomy', 'category', {
111
- context: 'view',
112
- per_page: -1,
113
- _fields: [ 'id' ],
114
- slug: categorySlug,
115
- } );
116
-
117
104
  const { posts, blocks } = useSelect(
118
105
  ( select ) => {
119
106
  const { getEntityRecords, getTaxonomies } = select( coreStore );
@@ -123,12 +110,22 @@ export default function PostTemplateEdit( {
123
110
  per_page: -1,
124
111
  context: 'view',
125
112
  } );
113
+ const templateCategory =
114
+ inherit &&
115
+ templateSlug?.startsWith( 'category-' ) &&
116
+ getEntityRecords( 'taxonomy', 'category', {
117
+ context: 'view',
118
+ per_page: 1,
119
+ _fields: [ 'id' ],
120
+ slug: templateSlug.replace( 'category-', '' ),
121
+ } );
126
122
  const query = {
127
123
  offset: perPage ? perPage * ( page - 1 ) + offset : 0,
128
124
  order,
129
125
  orderby: orderBy,
130
126
  };
131
- if ( taxQuery ) {
127
+ // There is no need to build the taxQuery if we inherit.
128
+ if ( taxQuery && ! inherit ) {
132
129
  // We have to build the tax query for the REST API and use as
133
130
  // keys the taxonomies `rest_base` with the `term ids` as values.
134
131
  const builtTaxQuery = Object.entries( taxQuery ).reduce(
@@ -174,11 +171,8 @@ export default function PostTemplateEdit( {
174
171
  if ( templateSlug?.startsWith( 'archive-' ) ) {
175
172
  query.postType = templateSlug.replace( 'archive-', '' );
176
173
  postType = query.postType;
177
- } else if ( !! categorySlug && hasResolvedCategories ) {
178
- query.taxQuery = {
179
- category: categories.map( ( { id } ) => id ),
180
- };
181
- taxQuery = query.taxQuery;
174
+ } else if ( templateCategory ) {
175
+ query.categories = templateCategory[ 0 ]?.id;
182
176
  }
183
177
  }
184
178
  // When we preview Query Loop blocks we should prefer the current
@@ -210,9 +204,6 @@ export default function PostTemplateEdit( {
210
204
  parents,
211
205
  restQueryArgs,
212
206
  previewPostType,
213
- categories,
214
- categorySlug,
215
- hasResolvedCategories,
216
207
  ]
217
208
  );
218
209
  const blockContexts = useMemo(
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { debounce } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -18,6 +13,7 @@ import {
18
13
  } from '@wordpress/components';
19
14
  import { __ } from '@wordpress/i18n';
20
15
  import { InspectorControls } from '@wordpress/block-editor';
16
+ import { debounce } from '@wordpress/compose';
21
17
  import { useEffect, useState, useCallback } from '@wordpress/element';
22
18
 
23
19
  /**
@@ -137,7 +133,7 @@ export default function QueryInspectorControls( {
137
133
  label={ __( 'Post type' ) }
138
134
  onChange={ onPostTypeChange }
139
135
  help={ __(
140
- 'WordPress contains different types of content and they are divided into collections called "Post types". By default there are a few different ones such as blog posts and pages, but plugins could add more.'
136
+ 'WordPress contains different types of content and they are divided into collections called Post types”. By default there are a few different ones such as blog posts and pages, but plugins could add more.'
141
137
  ) }
142
138
  />
143
139
  ) }
@@ -18,7 +18,7 @@ export default function StickyControl( { value, onChange } ) {
18
18
  value={ value }
19
19
  onChange={ onChange }
20
20
  help={ __(
21
- 'Blog posts can be "stickied", a feature that places them at the top of the front page of posts, keeping it there until new sticky posts are published.'
21
+ 'Blog posts can be stickied”, a feature that places them at the top of the front page of posts, keeping it there until new sticky posts are published.'
22
22
  ) }
23
23
  />
24
24
  );
@@ -48,7 +48,10 @@ export default function QueryPlaceholder( {
48
48
  );
49
49
 
50
50
  const matchingVariation = getMatchingVariation( attributes, allVariations );
51
- const icon = matchingVariation?.icon || blockType?.icon?.src;
51
+ const icon =
52
+ matchingVariation?.icon?.src ||
53
+ matchingVariation?.icon ||
54
+ blockType?.icon?.src;
52
55
  const label = matchingVariation?.title || blockType?.title;
53
56
  if ( isStartingBlank ) {
54
57
  return (
@@ -85,7 +85,7 @@ export default function QueryTitleEdit( {
85
85
 
86
86
  <TagName { ...blockProps }>
87
87
  { showSearchTerm
88
- ? __( 'Search results for: "search term"' )
88
+ ? __( 'Search results for: search term' )
89
89
  : __( 'Search results' ) }
90
90
  </TagName>
91
91
  </>
@@ -17,7 +17,7 @@ const transforms = {
17
17
  fontSize,
18
18
  style,
19
19
  },
20
- createBlock( 'core/paragraph', { content: value } )
20
+ [ createBlock( 'core/paragraph', { content: value } ) ]
21
21
  );
22
22
  },
23
23
  },
@@ -33,7 +33,7 @@ export default function ReadMore( {
33
33
  </InspectorControls>
34
34
  <RichText
35
35
  tagName="a"
36
- aria-label={ __( '"Read more" link text' ) }
36
+ aria-label={ __( 'Read more link text' ) }
37
37
  placeholder={ __( 'Read more' ) }
38
38
  value={ content }
39
39
  onChange={ ( newValue ) =>
@@ -4,7 +4,7 @@
4
4
  "name": "core/site-tagline",
5
5
  "title": "Site Tagline",
6
6
  "category": "theme",
7
- "description": "Describe in a few words what the site is about. The tagline can be used in search results or when sharing on social networks even if it's not displayed in the theme design.",
7
+ "description": "Describe in a few words what the site is about. The tagline can be used in search results or when sharing on social networks even if its not displayed in the theme design.",
8
8
  "keywords": [ "description" ],
9
9
  "textdomain": "default",
10
10
  "attributes": {
@@ -69,7 +69,13 @@ function SocialLinksEdit( {
69
69
 
70
70
  function renderPlaceholder() {
71
71
  return [ ...new Array( innerBlocks.length || 1 ) ].map(
72
- ( _, index ) => <View style={ placeholderStyle } key={ index } />
72
+ ( _, index ) => (
73
+ <View
74
+ testID="social-links-placeholder"
75
+ style={ placeholderStyle }
76
+ key={ index }
77
+ />
78
+ )
73
79
  );
74
80
  }
75
81
 
@@ -0,0 +1,57 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Social links block inserts block with the default icons and the WordPress link set as active 1`] = `
4
+ "<!-- wp:social-links -->
5
+ <ul class=\\"wp-block-social-links\\"><!-- wp:social-link {\\"url\\":\\"https://wordpress.org\\",\\"service\\":\\"wordpress\\"} /-->
6
+
7
+ <!-- wp:social-link {\\"service\\":\\"facebook\\"} /-->
8
+
9
+ <!-- wp:social-link {\\"service\\":\\"twitter\\"} /-->
10
+
11
+ <!-- wp:social-link {\\"service\\":\\"instagram\\"} /--></ul>
12
+ <!-- /wp:social-links -->"
13
+ `;
14
+
15
+ exports[`Social links block shows active links correctly when not selected 1`] = `
16
+ "<!-- wp:social-links -->
17
+ <ul class=\\"wp-block-social-links\\"><!-- wp:social-link {\\"url\\":\\"https://wordpress.org\\",\\"service\\":\\"wordpress\\"} /-->
18
+
19
+ <!-- wp:social-link {\\"service\\":\\"facebook\\"} /-->
20
+
21
+ <!-- wp:social-link {\\"service\\":\\"twitter\\"} /-->
22
+
23
+ <!-- wp:social-link {\\"service\\":\\"instagram\\"} /--></ul>
24
+ <!-- /wp:social-links -->
25
+
26
+ <!-- wp:paragraph -->
27
+ <p></p>
28
+ <!-- /wp:paragraph -->"
29
+ `;
30
+
31
+ exports[`Social links block shows the ghost placeholder when no icon is active 1`] = `
32
+ "<!-- wp:social-links -->
33
+ <ul class=\\"wp-block-social-links\\"><!-- wp:social-link {\\"service\\":\\"facebook\\"} /-->
34
+
35
+ <!-- wp:social-link {\\"service\\":\\"twitter\\"} /-->
36
+
37
+ <!-- wp:social-link {\\"service\\":\\"instagram\\"} /--></ul>
38
+ <!-- /wp:social-links -->
39
+
40
+ <!-- wp:paragraph -->
41
+ <p></p>
42
+ <!-- /wp:paragraph -->"
43
+ `;
44
+
45
+ exports[`Social links block shows the social links bottom sheet when tapping on the inline appender 1`] = `
46
+ "<!-- wp:social-links -->
47
+ <ul class=\\"wp-block-social-links\\"><!-- wp:social-link {\\"url\\":\\"https://wordpress.org\\",\\"service\\":\\"wordpress\\"} /-->
48
+
49
+ <!-- wp:social-link {\\"service\\":\\"facebook\\"} /-->
50
+
51
+ <!-- wp:social-link {\\"service\\":\\"twitter\\"} /-->
52
+
53
+ <!-- wp:social-link {\\"service\\":\\"instagram\\"} /-->
54
+
55
+ <!-- wp:social-link-amazon {\\"url\\":\\"\\"} /--></ul>
56
+ <!-- /wp:social-links -->"
57
+ `;