@wordpress/block-library 7.14.2 → 7.15.1-next.4d3b314fd5.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 (235) hide show
  1. package/CHANGELOG.md +3 -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 +8 -1
  15. package/build/comments-pagination-numbers/index.js.map +1 -1
  16. package/build/comments-pagination-previous/index.js +1 -1
  17. package/build/comments-title/edit.js +1 -1
  18. package/build/comments-title/edit.js.map +1 -1
  19. package/build/cover/edit/use-cover-is-dark.js +10 -7
  20. package/build/cover/edit/use-cover-is-dark.js.map +1 -1
  21. package/build/cover/index.js +9 -2
  22. package/build/cover/index.js.map +1 -1
  23. package/build/embed/deprecated.js +12 -6
  24. package/build/embed/deprecated.js.map +1 -1
  25. package/build/embed/index.js +12 -6
  26. package/build/embed/index.js.map +1 -1
  27. package/build/embed/transforms.js +12 -6
  28. package/build/embed/transforms.js.map +1 -1
  29. package/build/embed/util.js +12 -6
  30. package/build/embed/util.js.map +1 -1
  31. package/build/embed/variations.js +1 -1
  32. package/build/embed/variations.js.map +1 -1
  33. package/build/freeform/edit.js +5 -8
  34. package/build/freeform/edit.js.map +1 -1
  35. package/build/gallery/deprecated.js +4 -4
  36. package/build/gallery/deprecated.js.map +1 -1
  37. package/build/gallery/gallery.js +2 -28
  38. package/build/gallery/gallery.js.map +1 -1
  39. package/build/list-item/edit.js +2 -1
  40. package/build/list-item/edit.js.map +1 -1
  41. package/build/missing/edit.js +9 -2
  42. package/build/missing/edit.js.map +1 -1
  43. package/build/more/edit.js +1 -1
  44. package/build/more/edit.js.map +1 -1
  45. package/build/navigation/menu-items-to-blocks.js +16 -6
  46. package/build/navigation/menu-items-to-blocks.js.map +1 -1
  47. package/build/paragraph/drop-zone.js +99 -0
  48. package/build/paragraph/drop-zone.js.map +1 -0
  49. package/build/paragraph/edit.js +11 -3
  50. package/build/paragraph/edit.js.map +1 -1
  51. package/build/post-content/edit.js +6 -1
  52. package/build/post-content/edit.js.map +1 -1
  53. package/build/post-excerpt/edit.js +1 -1
  54. package/build/post-excerpt/edit.js.map +1 -1
  55. package/build/post-navigation-link/edit.js +35 -4
  56. package/build/post-navigation-link/edit.js.map +1 -1
  57. package/build/post-navigation-link/index.js +6 -1
  58. package/build/post-navigation-link/index.js.map +1 -1
  59. package/build/post-template/edit.js +13 -28
  60. package/build/post-template/edit.js.map +1 -1
  61. package/build/query/edit/inspector-controls/index.js +4 -8
  62. package/build/query/edit/inspector-controls/index.js.map +1 -1
  63. package/build/query/edit/inspector-controls/sticky-control.js +1 -1
  64. package/build/query/edit/inspector-controls/sticky-control.js.map +1 -1
  65. package/build/query/edit/query-placeholder.js +2 -2
  66. package/build/query/edit/query-placeholder.js.map +1 -1
  67. package/build/query-title/edit.js +1 -1
  68. package/build/query-title/edit.js.map +1 -1
  69. package/build/quote/transforms.js +2 -2
  70. package/build/quote/transforms.js.map +1 -1
  71. package/build/read-more/edit.js +1 -1
  72. package/build/read-more/edit.js.map +1 -1
  73. package/build/site-tagline/index.js +1 -1
  74. package/build/social-links/edit.native.js +1 -0
  75. package/build/social-links/edit.native.js.map +1 -1
  76. package/build/template-part/edit/index.js +2 -2
  77. package/build/template-part/edit/index.js.map +1 -1
  78. package/build-module/avatar/index.js +1 -1
  79. package/build-module/block/edit.native.js +1 -1
  80. package/build-module/block/edit.native.js.map +1 -1
  81. package/build-module/buttons/edit.native.js +1 -2
  82. package/build-module/buttons/edit.native.js.map +1 -1
  83. package/build-module/calendar/index.js +9 -0
  84. package/build-module/calendar/index.js.map +1 -1
  85. package/build-module/code/index.js +1 -1
  86. package/build-module/code/index.js.map +1 -1
  87. package/build-module/comments/edit/comments-legacy.js +1 -1
  88. package/build-module/comments/edit/comments-legacy.js.map +1 -1
  89. package/build-module/comments-pagination-next/index.js +1 -1
  90. package/build-module/comments-pagination-numbers/index.js +8 -1
  91. package/build-module/comments-pagination-numbers/index.js.map +1 -1
  92. package/build-module/comments-pagination-previous/index.js +1 -1
  93. package/build-module/comments-title/edit.js +1 -1
  94. package/build-module/comments-title/edit.js.map +1 -1
  95. package/build-module/cover/edit/use-cover-is-dark.js +9 -4
  96. package/build-module/cover/edit/use-cover-is-dark.js.map +1 -1
  97. package/build-module/cover/index.js +9 -2
  98. package/build-module/cover/index.js.map +1 -1
  99. package/build-module/embed/deprecated.js +12 -6
  100. package/build-module/embed/deprecated.js.map +1 -1
  101. package/build-module/embed/index.js +12 -6
  102. package/build-module/embed/index.js.map +1 -1
  103. package/build-module/embed/transforms.js +12 -6
  104. package/build-module/embed/transforms.js.map +1 -1
  105. package/build-module/embed/util.js +12 -6
  106. package/build-module/embed/util.js.map +1 -1
  107. package/build-module/embed/variations.js +1 -1
  108. package/build-module/embed/variations.js.map +1 -1
  109. package/build-module/freeform/edit.js +3 -6
  110. package/build-module/freeform/edit.js.map +1 -1
  111. package/build-module/gallery/deprecated.js +4 -4
  112. package/build-module/gallery/deprecated.js.map +1 -1
  113. package/build-module/gallery/gallery.js +2 -29
  114. package/build-module/gallery/gallery.js.map +1 -1
  115. package/build-module/list-item/edit.js +2 -1
  116. package/build-module/list-item/edit.js.map +1 -1
  117. package/build-module/missing/edit.js +11 -4
  118. package/build-module/missing/edit.js.map +1 -1
  119. package/build-module/more/edit.js +1 -1
  120. package/build-module/more/edit.js.map +1 -1
  121. package/build-module/navigation/menu-items-to-blocks.js +16 -6
  122. package/build-module/navigation/menu-items-to-blocks.js.map +1 -1
  123. package/build-module/paragraph/drop-zone.js +88 -0
  124. package/build-module/paragraph/drop-zone.js.map +1 -0
  125. package/build-module/paragraph/edit.js +10 -3
  126. package/build-module/paragraph/edit.js.map +1 -1
  127. package/build-module/post-content/edit.js +6 -1
  128. package/build-module/post-content/edit.js.map +1 -1
  129. package/build-module/post-excerpt/edit.js +1 -1
  130. package/build-module/post-excerpt/edit.js.map +1 -1
  131. package/build-module/post-navigation-link/edit.js +37 -6
  132. package/build-module/post-navigation-link/edit.js.map +1 -1
  133. package/build-module/post-navigation-link/index.js +6 -1
  134. package/build-module/post-navigation-link/index.js.map +1 -1
  135. package/build-module/post-template/edit.js +14 -29
  136. package/build-module/post-template/edit.js.map +1 -1
  137. package/build-module/query/edit/inspector-controls/index.js +2 -6
  138. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  139. package/build-module/query/edit/inspector-controls/sticky-control.js +1 -1
  140. package/build-module/query/edit/inspector-controls/sticky-control.js.map +1 -1
  141. package/build-module/query/edit/query-placeholder.js +2 -2
  142. package/build-module/query/edit/query-placeholder.js.map +1 -1
  143. package/build-module/query-title/edit.js +1 -1
  144. package/build-module/query-title/edit.js.map +1 -1
  145. package/build-module/quote/transforms.js +2 -2
  146. package/build-module/quote/transforms.js.map +1 -1
  147. package/build-module/read-more/edit.js +1 -1
  148. package/build-module/read-more/edit.js.map +1 -1
  149. package/build-module/site-tagline/index.js +1 -1
  150. package/build-module/social-links/edit.native.js +1 -0
  151. package/build-module/social-links/edit.native.js.map +1 -1
  152. package/build-module/template-part/edit/index.js +3 -3
  153. package/build-module/template-part/edit/index.js.map +1 -1
  154. package/build-style/calendar/style-rtl.css +21 -12
  155. package/build-style/calendar/style.css +21 -12
  156. package/build-style/classic-rtl.css +85 -0
  157. package/build-style/classic.css +85 -0
  158. package/build-style/editor-rtl.css +41 -2
  159. package/build-style/editor.css +41 -2
  160. package/build-style/group/editor-rtl.css +11 -1
  161. package/build-style/group/editor.css +11 -1
  162. package/build-style/image/editor-rtl.css +3 -0
  163. package/build-style/image/editor.css +3 -0
  164. package/build-style/navigation/editor-rtl.css +11 -1
  165. package/build-style/navigation/editor.css +11 -1
  166. package/build-style/paragraph/editor-rtl.css +16 -0
  167. package/build-style/paragraph/editor.css +16 -0
  168. package/build-style/post-navigation-link/style-rtl.css +90 -0
  169. package/build-style/post-navigation-link/style.css +90 -0
  170. package/build-style/style-rtl.css +36 -12
  171. package/build-style/style.css +36 -12
  172. package/package.json +29 -29
  173. package/src/archives/index.php +4 -7
  174. package/src/avatar/block.json +1 -1
  175. package/src/block/edit.native.js +1 -1
  176. package/src/buttons/edit.native.js +1 -2
  177. package/src/buttons/test/__snapshots__/edit.native.js.snap +28 -0
  178. package/src/buttons/test/edit.native.js +170 -0
  179. package/src/calendar/block.json +9 -0
  180. package/src/calendar/index.php +22 -1
  181. package/src/calendar/style.scss +28 -15
  182. package/src/classic.scss +15 -0
  183. package/src/code/index.js +1 -1
  184. package/src/columns/test/__snapshots__/edit.native.js.snap +219 -0
  185. package/src/columns/test/edit.native.js +432 -0
  186. package/src/comment-template/index.php +18 -8
  187. package/src/comments/edit/comments-legacy.js +1 -1
  188. package/src/comments-pagination-next/block.json +1 -1
  189. package/src/comments-pagination-numbers/block.json +8 -1
  190. package/src/comments-pagination-previous/block.json +1 -1
  191. package/src/comments-title/edit.js +1 -1
  192. package/src/cover/edit/use-cover-is-dark.js +11 -7
  193. package/src/cover/index.js +8 -1
  194. package/src/cover/test/__snapshots__/edit.native.js.snap +64 -0
  195. package/src/cover/test/edit.native.js +136 -4
  196. package/src/embed/block.json +12 -6
  197. package/src/embed/test/index.native.js +1 -2
  198. package/src/embed/variations.js +1 -1
  199. package/src/freeform/edit.js +12 -10
  200. package/src/gallery/deprecated.js +4 -4
  201. package/src/gallery/gallery.js +1 -31
  202. package/src/group/test/__snapshots__/edit.native.js.snap +19 -0
  203. package/src/group/test/edit.native.js +102 -0
  204. package/src/image/editor.scss +4 -0
  205. package/src/list-item/edit.js +1 -0
  206. package/src/missing/edit.js +15 -4
  207. package/src/more/edit.js +1 -1
  208. package/src/navigation/menu-items-to-blocks.js +39 -22
  209. package/src/navigation/test/menu-items-to-blocks.js +6 -0
  210. package/src/navigation-submenu/index.php +11 -2
  211. package/src/page-list/index.php +1 -1
  212. package/src/paragraph/drop-zone.js +105 -0
  213. package/src/paragraph/edit.js +14 -1
  214. package/src/paragraph/editor.scss +20 -0
  215. package/src/post-content/edit.js +3 -1
  216. package/src/post-excerpt/edit.js +1 -1
  217. package/src/post-featured-image/index.php +11 -18
  218. package/src/post-navigation-link/block.json +6 -1
  219. package/src/post-navigation-link/edit.js +64 -3
  220. package/src/post-navigation-link/index.php +23 -0
  221. package/src/post-navigation-link/style.scss +23 -0
  222. package/src/post-template/edit.js +14 -23
  223. package/src/query/edit/inspector-controls/index.js +2 -6
  224. package/src/query/edit/inspector-controls/sticky-control.js +1 -1
  225. package/src/query/edit/query-placeholder.js +4 -1
  226. package/src/query-title/edit.js +1 -1
  227. package/src/quote/transforms.js +1 -1
  228. package/src/read-more/edit.js +1 -1
  229. package/src/site-tagline/block.json +1 -1
  230. package/src/social-links/edit.native.js +7 -1
  231. package/src/social-links/test/__snapshots__/edit.native.js.snap +57 -0
  232. package/src/social-links/test/edit.native.js +199 -0
  233. package/src/style.scss +1 -0
  234. package/src/tag-cloud/index.php +1 -8
  235. package/src/template-part/edit/index.js +60 -58
@@ -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
+ `;
@@ -0,0 +1,199 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import {
5
+ addBlock,
6
+ fireEvent,
7
+ getEditorHtml,
8
+ initializeEditor,
9
+ within,
10
+ getBlock,
11
+ waitFor,
12
+ } from 'test/helpers';
13
+
14
+ /**
15
+ * WordPress dependencies
16
+ */
17
+ import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
18
+ import { registerCoreBlocks } from '@wordpress/block-library';
19
+
20
+ beforeAll( () => {
21
+ // Register all core blocks
22
+ registerCoreBlocks();
23
+ } );
24
+
25
+ afterAll( () => {
26
+ // Clean up registered blocks
27
+ getBlockTypes().forEach( ( block ) => {
28
+ unregisterBlockType( block.name );
29
+ } );
30
+ } );
31
+
32
+ describe( 'Social links block', () => {
33
+ it( 'inserts block with the default icons and the WordPress link set as active', async () => {
34
+ const screen = await initializeEditor();
35
+
36
+ // Add block
37
+ await addBlock( screen, 'Social Icons' );
38
+
39
+ // Get block
40
+ const socialLinksBlock = await getBlock( screen, 'Social Icons' );
41
+
42
+ // Trigger inner blocks layout
43
+ const innerBlockListWrapper = await waitFor( () =>
44
+ within( socialLinksBlock ).getByTestId( 'block-list-wrapper' )
45
+ );
46
+ fireEvent( innerBlockListWrapper, 'layout', {
47
+ nativeEvent: {
48
+ layout: {
49
+ width: 300,
50
+ },
51
+ },
52
+ } );
53
+
54
+ // Check the WordPress icon has a URL set (active)
55
+ const firstLinkBlock = await getBlock( screen, 'Social Icon' );
56
+ fireEvent.press( firstLinkBlock );
57
+ const firstLink = within( socialLinksBlock ).getByAccessibilityHint(
58
+ /WordPress has URL set/
59
+ );
60
+ expect( firstLink ).toBeVisible();
61
+
62
+ expect( getEditorHtml() ).toMatchSnapshot();
63
+ } );
64
+
65
+ it( 'shows active links correctly when not selected', async () => {
66
+ const screen = await initializeEditor();
67
+
68
+ // Add Social Icons block
69
+ await addBlock( screen, 'Social Icons' );
70
+
71
+ // Get block
72
+ const socialLinksBlock = await getBlock( screen, 'Social Icons' );
73
+
74
+ // Trigger inner blocks layout
75
+ const innerBlockListWrapper = await waitFor( () =>
76
+ within( socialLinksBlock ).getByTestId( 'block-list-wrapper' )
77
+ );
78
+ fireEvent( innerBlockListWrapper, 'layout', {
79
+ nativeEvent: {
80
+ layout: {
81
+ width: 300,
82
+ },
83
+ },
84
+ } );
85
+
86
+ // Add Paragraph block
87
+ await addBlock( screen, 'Paragraph' );
88
+
89
+ // Check there's only one active social link
90
+ const socialLinks =
91
+ within( socialLinksBlock ).getAllByA11yLabel( / social icon/ );
92
+ expect( socialLinks.length ).toBe( 1 );
93
+
94
+ // Check the WordPress link is shown when unselected
95
+ const firstLinkBlock = await getBlock( screen, 'Social Icon' );
96
+ fireEvent.press( firstLinkBlock );
97
+ const firstLink = within( socialLinksBlock ).getByAccessibilityHint(
98
+ /WordPress has URL set/
99
+ );
100
+ expect( firstLink ).toBeVisible();
101
+
102
+ expect( getEditorHtml() ).toMatchSnapshot();
103
+ } );
104
+
105
+ it( 'shows the social links bottom sheet when tapping on the inline appender', async () => {
106
+ const screen = await initializeEditor();
107
+ const { getByTestId, getByText } = screen;
108
+
109
+ // Add block
110
+ await addBlock( screen, 'Social Icons' );
111
+
112
+ // Get block
113
+ const socialLinksBlock = await getBlock( screen, 'Social Icons' );
114
+ fireEvent.press( socialLinksBlock );
115
+
116
+ // Trigger inner blocks layout
117
+ const innerBlockListWrapper = await waitFor( () =>
118
+ within( socialLinksBlock ).getByTestId( 'block-list-wrapper' )
119
+ );
120
+ fireEvent( innerBlockListWrapper, 'layout', {
121
+ nativeEvent: {
122
+ layout: {
123
+ width: 300,
124
+ },
125
+ },
126
+ } );
127
+
128
+ // Open the links bottom sheet
129
+ const appenderButton =
130
+ within( socialLinksBlock ).getByTestId( 'appender-button' );
131
+ fireEvent.press( appenderButton );
132
+
133
+ // Find a social link in the inserter
134
+ const blockList = getByTestId( 'InserterUI-Blocks' );
135
+
136
+ // onScroll event used to force the FlatList to render all items
137
+ fireEvent.scroll( blockList, {
138
+ nativeEvent: {
139
+ contentOffset: { y: 0, x: 0 },
140
+ contentSize: { width: 100, height: 100 },
141
+ layoutMeasurement: { width: 100, height: 100 },
142
+ },
143
+ } );
144
+
145
+ // Add the Amazon link
146
+ const amazonBlock = await waitFor( () => getByText( 'Amazon' ) );
147
+ expect( amazonBlock ).toBeVisible();
148
+
149
+ fireEvent.press( amazonBlock );
150
+
151
+ expect( getEditorHtml() ).toMatchSnapshot();
152
+ } );
153
+
154
+ it( 'shows the ghost placeholder when no icon is active', async () => {
155
+ const screen = await initializeEditor();
156
+ const { getByA11yLabel } = screen;
157
+
158
+ // Add block
159
+ await addBlock( screen, 'Social Icons' );
160
+
161
+ // Get block
162
+ const socialLinksBlock = await getBlock( screen, 'Social Icons' );
163
+
164
+ // Trigger inner blocks layout
165
+ const innerBlockListWrapper = await waitFor( () =>
166
+ within( socialLinksBlock ).getByTestId( 'block-list-wrapper' )
167
+ );
168
+ fireEvent( innerBlockListWrapper, 'layout', {
169
+ nativeEvent: {
170
+ layout: {
171
+ width: 300,
172
+ },
173
+ },
174
+ } );
175
+
176
+ // Get the first social link
177
+ const firstLinkBlock = await getBlock( screen, 'Social Icon' );
178
+ fireEvent.press( firstLinkBlock );
179
+
180
+ // Open block actions menu
181
+ const blockActionsButton = getByA11yLabel( /Open Block Actions Menu/ );
182
+ fireEvent.press( blockActionsButton );
183
+
184
+ // Delete the social link
185
+ const deleteButton = getByA11yLabel( /Remove block/ );
186
+ fireEvent.press( deleteButton );
187
+
188
+ // Add Paragraph block
189
+ await addBlock( screen, 'Paragraph' );
190
+
191
+ // Check the ghost placeholders are visible
192
+ const socialLinks = within( socialLinksBlock ).getAllByTestId(
193
+ 'social-links-placeholder'
194
+ );
195
+ expect( socialLinks.length ).toBe( 3 );
196
+
197
+ expect( getEditorHtml() ).toMatchSnapshot();
198
+ } );
199
+ } );
package/src/style.scss CHANGED
@@ -30,6 +30,7 @@
30
30
  @import "./post-date/style.scss";
31
31
  @import "./post-excerpt/style.scss";
32
32
  @import "./post-featured-image/style.scss";
33
+ @import "./post-navigation-link/style.scss";
33
34
  @import "./post-terms/style.scss";
34
35
  @import "./post-title/style.scss";
35
36
  @import "./preformatted/style.scss";
@@ -28,14 +28,7 @@ function render_block_core_tag_cloud( $attributes ) {
28
28
  $tag_cloud = wp_tag_cloud( $args );
29
29
 
30
30
  if ( ! $tag_cloud ) {
31
- $labels = get_taxonomy_labels( get_taxonomy( $attributes['taxonomy'] ) );
32
- $tag_cloud = esc_html(
33
- sprintf(
34
- /* translators: %s: taxonomy name */
35
- __( 'Your site doesn&#8217;t have any %s, so there&#8217;s nothing to display here at the moment.' ),
36
- strtolower( $labels->name )
37
- )
38
- );
31
+ $tag_cloud = __( 'There&#8217;s no content to show here yet.' );
39
32
  }
40
33
 
41
34
  $wrapper_attributes = get_block_wrapper_attributes();