@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
@@ -104,7 +104,7 @@ export default function Edit( {
104
104
  </InspectorControls>
105
105
  );
106
106
 
107
- const postTitle = isSiteEditor ? __( '"Post Title"' ) : `"${ rawTitle }"`;
107
+ const postTitle = isSiteEditor ? __( 'Post Title' ) : `"${ rawTitle }"`;
108
108
 
109
109
  let placeholder;
110
110
  if ( showCommentsCount && commentsCount !== undefined ) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import FastAverageColor from 'fast-average-color';
4
+ import { FastAverageColor } from 'fast-average-color';
5
5
  import { colord } from 'colord';
6
6
 
7
7
  /**
@@ -41,12 +41,16 @@ export default function useCoverIsDark(
41
41
  // If opacity is lower than 50 the dominant color is the image or video color,
42
42
  // so use that color for the dark mode computation.
43
43
  if ( url && dimRatio <= 50 && elementRef.current ) {
44
- retrieveFastAverageColor().getColorAsync(
45
- elementRef.current,
46
- ( color ) => {
47
- setIsDark( color.isDark );
48
- }
49
- );
44
+ retrieveFastAverageColor()
45
+ .getColorAsync( elementRef.current, {
46
+ // Previously the default color was white, but that changed
47
+ // in v6.0.0 so it has to be manually set now.
48
+ defaultColor: [ 255, 255, 255, 255 ],
49
+ // Errors that come up don't reject the promise, so error
50
+ // logging has to be silenced with this option.
51
+ silent: process.env.NODE_ENV === 'production',
52
+ } )
53
+ .then( ( color ) => setIsDark( color.isDark ) );
50
54
  }
51
55
  }, [ url, url && dimRatio <= 50 && elementRef.current, setIsDark ] );
52
56
  useEffect( () => {
@@ -30,9 +30,16 @@ export const settings = {
30
30
  {
31
31
  name: 'core/paragraph',
32
32
  attributes: {
33
- customFontSize: 48,
34
33
  content: __( '<strong>Snow Patrol</strong>' ),
35
34
  align: 'center',
35
+ style: {
36
+ typography: {
37
+ fontSize: 48,
38
+ },
39
+ color: {
40
+ text: 'white',
41
+ },
42
+ },
36
43
  },
37
44
  },
38
45
  ],
@@ -31,3 +31,67 @@ exports[`color settings toggles between solid colors and gradients 1`] = `
31
31
  <!-- /wp:paragraph --></div></div>
32
32
  <!-- /wp:cover -->"
33
33
  `;
34
+
35
+ exports[`minimum height settings changes the height value between units 1`] = `
36
+ "<!-- wp:cover {\\"url\\":\\"https://cldup.com/cXyG__fTLN.jpg\\",\\"id\\":10710,\\"dimRatio\\":50,\\"overlayColor\\":\\"foreground\\",\\"minHeight\\":50,\\"minHeightUnit\\":\\"px\\",\\"isDark\\":false} -->
37
+ <div class=\\"wp-block-cover is-light\\" style=\\"min-height:50px\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-foreground-background-color has-background-dim\\"></span><img class=\\"wp-block-cover__image-background wp-image-10710\\" alt=\\"\\" src=\\"https://cldup.com/cXyG__fTLN.jpg\\" data-object-fit=\\"cover\\"/><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\",\\"fontSize\\":\\"large\\"} -->
38
+ <p class=\\"has-text-align-center has-large-font-size\\"></p>
39
+ <!-- /wp:paragraph --></div></div>
40
+ <!-- /wp:cover -->"
41
+ `;
42
+
43
+ exports[`minimum height settings changes the height value to 20(vw) 1`] = `
44
+ "<!-- wp:cover {\\"url\\":\\"https://cldup.com/cXyG__fTLN.jpg\\",\\"id\\":10710,\\"dimRatio\\":50,\\"overlayColor\\":\\"foreground\\",\\"minHeight\\":20,\\"minHeightUnit\\":\\"vw\\",\\"isDark\\":false} -->
45
+ <div class=\\"wp-block-cover is-light\\" style=\\"min-height:20vw\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-foreground-background-color has-background-dim\\"></span><img class=\\"wp-block-cover__image-background wp-image-10710\\" alt=\\"\\" src=\\"https://cldup.com/cXyG__fTLN.jpg\\" data-object-fit=\\"cover\\"/><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\",\\"fontSize\\":\\"large\\"} -->
46
+ <p class=\\"has-text-align-center has-large-font-size\\"></p>
47
+ <!-- /wp:paragraph --></div></div>
48
+ <!-- /wp:cover -->"
49
+ `;
50
+
51
+ exports[`minimum height settings disables the decrease button when reaching the minimum value for Pixels (px) 1`] = `
52
+ "<!-- wp:cover {\\"url\\":\\"https://cldup.com/cXyG__fTLN.jpg\\",\\"id\\":10710,\\"dimRatio\\":50,\\"overlayColor\\":\\"foreground\\",\\"minHeight\\":50,\\"minHeightUnit\\":\\"px\\",\\"isDark\\":false} -->
53
+ <div class=\\"wp-block-cover is-light\\" style=\\"min-height:50px\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-foreground-background-color has-background-dim\\"></span><img class=\\"wp-block-cover__image-background wp-image-10710\\" alt=\\"\\" src=\\"https://cldup.com/cXyG__fTLN.jpg\\" data-object-fit=\\"cover\\"/><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\",\\"fontSize\\":\\"large\\"} -->
54
+ <p class=\\"has-text-align-center has-large-font-size\\"></p>
55
+ <!-- /wp:paragraph --></div></div>
56
+ <!-- /wp:cover -->"
57
+ `;
58
+
59
+ exports[`minimum height settings disables the decrease button when reaching the minimum value for Relative to parent font size (em) 1`] = `
60
+ "<!-- wp:cover {\\"url\\":\\"https://cldup.com/cXyG__fTLN.jpg\\",\\"id\\":10710,\\"dimRatio\\":50,\\"overlayColor\\":\\"foreground\\",\\"minHeight\\":1,\\"minHeightUnit\\":\\"em\\",\\"isDark\\":false} -->
61
+ <div class=\\"wp-block-cover is-light\\" style=\\"min-height:1em\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-foreground-background-color has-background-dim\\"></span><img class=\\"wp-block-cover__image-background wp-image-10710\\" alt=\\"\\" src=\\"https://cldup.com/cXyG__fTLN.jpg\\" data-object-fit=\\"cover\\"/><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\",\\"fontSize\\":\\"large\\"} -->
62
+ <p class=\\"has-text-align-center has-large-font-size\\"></p>
63
+ <!-- /wp:paragraph --></div></div>
64
+ <!-- /wp:cover -->"
65
+ `;
66
+
67
+ exports[`minimum height settings disables the decrease button when reaching the minimum value for Relative to root font size (rem) 1`] = `
68
+ "<!-- wp:cover {\\"url\\":\\"https://cldup.com/cXyG__fTLN.jpg\\",\\"id\\":10710,\\"dimRatio\\":50,\\"overlayColor\\":\\"foreground\\",\\"minHeight\\":1,\\"minHeightUnit\\":\\"rem\\",\\"isDark\\":false} -->
69
+ <div class=\\"wp-block-cover is-light\\" style=\\"min-height:1rem\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-foreground-background-color has-background-dim\\"></span><img class=\\"wp-block-cover__image-background wp-image-10710\\" alt=\\"\\" src=\\"https://cldup.com/cXyG__fTLN.jpg\\" data-object-fit=\\"cover\\"/><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\",\\"fontSize\\":\\"large\\"} -->
70
+ <p class=\\"has-text-align-center has-large-font-size\\"></p>
71
+ <!-- /wp:paragraph --></div></div>
72
+ <!-- /wp:cover -->"
73
+ `;
74
+
75
+ exports[`minimum height settings disables the decrease button when reaching the minimum value for Viewport height (vh) 1`] = `
76
+ "<!-- wp:cover {\\"url\\":\\"https://cldup.com/cXyG__fTLN.jpg\\",\\"id\\":10710,\\"dimRatio\\":50,\\"overlayColor\\":\\"foreground\\",\\"minHeight\\":1,\\"minHeightUnit\\":\\"vh\\",\\"isDark\\":false} -->
77
+ <div class=\\"wp-block-cover is-light\\" style=\\"min-height:1vh\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-foreground-background-color has-background-dim\\"></span><img class=\\"wp-block-cover__image-background wp-image-10710\\" alt=\\"\\" src=\\"https://cldup.com/cXyG__fTLN.jpg\\" data-object-fit=\\"cover\\"/><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\",\\"fontSize\\":\\"large\\"} -->
78
+ <p class=\\"has-text-align-center has-large-font-size\\"></p>
79
+ <!-- /wp:paragraph --></div></div>
80
+ <!-- /wp:cover -->"
81
+ `;
82
+
83
+ exports[`minimum height settings disables the decrease button when reaching the minimum value for Viewport width (vw) 1`] = `
84
+ "<!-- wp:cover {\\"url\\":\\"https://cldup.com/cXyG__fTLN.jpg\\",\\"id\\":10710,\\"dimRatio\\":50,\\"overlayColor\\":\\"foreground\\",\\"minHeight\\":1,\\"minHeightUnit\\":\\"vw\\",\\"isDark\\":false} -->
85
+ <div class=\\"wp-block-cover is-light\\" style=\\"min-height:1vw\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-foreground-background-color has-background-dim\\"></span><img class=\\"wp-block-cover__image-background wp-image-10710\\" alt=\\"\\" src=\\"https://cldup.com/cXyG__fTLN.jpg\\" data-object-fit=\\"cover\\"/><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\",\\"fontSize\\":\\"large\\"} -->
86
+ <p class=\\"has-text-align-center has-large-font-size\\"></p>
87
+ <!-- /wp:paragraph --></div></div>
88
+ <!-- /wp:cover -->"
89
+ `;
90
+
91
+ exports[`when an image is attached updates background opacity 1`] = `
92
+ "<!-- wp:cover {\\"url\\":\\"https://cldup.com/cXyG__fTLN.jpg\\",\\"id\\":10710,\\"dimRatio\\":15,\\"overlayColor\\":\\"foreground\\",\\"isDark\\":false} -->
93
+ <div class=\\"wp-block-cover is-light\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-foreground-background-color has-background-dim-20 has-background-dim\\"></span><img class=\\"wp-block-cover__image-background wp-image-10710\\" alt=\\"\\" src=\\"https://cldup.com/cXyG__fTLN.jpg\\" data-object-fit=\\"cover\\"/><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\",\\"fontSize\\":\\"large\\"} -->
94
+ <p class=\\"has-text-align-center has-large-font-size\\"></p>
95
+ <!-- /wp:paragraph --></div></div>
96
+ <!-- /wp:cover -->"
97
+ `;
@@ -9,6 +9,8 @@ import {
9
9
  fireEvent,
10
10
  waitFor,
11
11
  within,
12
+ getBlock,
13
+ openBlockSettings,
12
14
  } from 'test/helpers';
13
15
 
14
16
  /**
@@ -41,14 +43,24 @@ jest.mock( '@wordpress/compose', () => ( {
41
43
  ) ),
42
44
  } ) );
43
45
 
44
- const COVER_BLOCK_PLACEHOLDER_HTML = `<!-- wp:cover -->
45
- <div class="wp-block-cover"><span aria-hidden="true" class="has-background-dim-100 wp-block-cover__gradient-background has-background-dim"></span><div class="wp-block-cover__inner-container"></div></div>
46
+ const COVER_BLOCK_PLACEHOLDER_HTML = `<!-- wp:cover {"isDark":false} -->
47
+ <div class="wp-block-cover is-light"><span aria-hidden="true" class="wp-block-cover__background has-background-dim-100 has-background-dim"></span><div class="wp-block-cover__inner-container"></div></div>
46
48
  <!-- /wp:cover -->`;
47
- const COVER_BLOCK_SOLID_COLOR_HTML = `<!-- wp:cover {"overlayColor":"cyan-bluish-gray"} -->
48
- <div class="wp-block-cover"><span aria-hidden="true" class="has-cyan-bluish-gray-background-color has-background-dim-100 wp-block-cover__gradient-background has-background-dim"></span><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…"} -->
49
+ const COVER_BLOCK_SOLID_COLOR_HTML = `<!-- wp:cover {"overlayColor":"cyan-bluish-gray","isDark":false} -->
50
+ <div class="wp-block-cover is-light"><span aria-hidden="true" class="wp-block-cover__background has-cyan-bluish-gray-background-color has-background-dim-100 has-background-dim"></span><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…"} -->
49
51
  <p class="has-text-align-center"></p>
50
52
  <!-- /wp:paragraph --></div></div>
51
53
  <!-- /wp:cover -->`;
54
+ const COVER_BLOCK_IMAGE_HTML = `<!-- wp:cover {"url":"https://cldup.com/cXyG__fTLN.jpg","id":10710,"dimRatio":50,"overlayColor":"foreground","isDark":false} -->
55
+ <div class="wp-block-cover is-light"><span aria-hidden="true" class="wp-block-cover__background has-foreground-background-color has-background-dim"></span><img class="wp-block-cover__image-background wp-image-10710" alt="" src="https://cldup.com/cXyG__fTLN.jpg" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
56
+ <p class="has-text-align-center has-large-font-size"></p>
57
+ <!-- /wp:paragraph --></div></div>
58
+ <!-- /wp:cover -->`;
59
+ const COVER_BLOCK_CUSTOM_HEIGHT_HTML = `<!-- wp:cover {"url":"https://cldup.com/cXyG__fTLN.jpg","id":10710,"dimRatio":50,"overlayColor":"foreground","minHeight":20,"minHeightUnit":"vw","isDark":false} -->
60
+ <div class="wp-block-cover is-light" style="min-height:20vw"><span aria-hidden="true" class="wp-block-cover__background has-foreground-background-color has-background-dim"></span><img class="wp-block-cover__image-background wp-image-10710" alt="" src="https://cldup.com/cXyG__fTLN.jpg" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
61
+ <p class="has-text-align-center has-large-font-size"></p>
62
+ <!-- /wp:paragraph --></div></div>
63
+ <!-- /wp:cover -->`;
52
64
 
53
65
  const COLOR_PINK = '#f78da7';
54
66
  const COLOR_RED = '#cf2e2e';
@@ -290,6 +302,34 @@ describe( 'when an image is attached', () => {
290
302
  } )
291
303
  );
292
304
  } );
305
+
306
+ it( 'updates background opacity', async () => {
307
+ const screen = await initializeEditor( {
308
+ initialHtml: COVER_BLOCK_IMAGE_HTML,
309
+ } );
310
+ const { getByA11yLabel } = screen;
311
+
312
+ // Get block
313
+ const coverBlock = await getBlock( screen, 'Cover' );
314
+ fireEvent.press( coverBlock );
315
+
316
+ // Open block settings
317
+ await openBlockSettings( screen );
318
+
319
+ // Update Opacity attribute
320
+ const opacityControl = getByA11yLabel( /Opacity/ );
321
+ fireEvent.press( within( opacityControl ).getByText( '50' ) );
322
+ const heightTextInput =
323
+ within( opacityControl ).getByDisplayValue( '50' );
324
+ fireEvent.changeText( heightTextInput, '20' );
325
+
326
+ // The decreasing button should be disabled
327
+ fireEvent( opacityControl, 'accessibilityAction', {
328
+ nativeEvent: { actionName: 'decrement' },
329
+ } );
330
+
331
+ expect( getEditorHtml() ).toMatchSnapshot();
332
+ } );
293
333
  } );
294
334
 
295
335
  describe( 'color settings', () => {
@@ -533,3 +573,95 @@ describe( 'color settings', () => {
533
573
  expect( getEditorHtml() ).toMatchSnapshot();
534
574
  } );
535
575
  } );
576
+
577
+ describe( 'minimum height settings', () => {
578
+ it( 'changes the height value to 20(vw)', async () => {
579
+ const screen = await initializeEditor( {
580
+ initialHtml: COVER_BLOCK_IMAGE_HTML,
581
+ } );
582
+ const { getByText, getByDisplayValue } = screen;
583
+
584
+ // Get block
585
+ const coverBlock = await getBlock( screen, 'Cover' );
586
+ fireEvent.press( coverBlock );
587
+
588
+ // Open block settings
589
+ await openBlockSettings( screen );
590
+
591
+ // Set vw unit
592
+ fireEvent.press( getByText( 'px' ) );
593
+ fireEvent.press( getByText( 'Viewport width (vw)' ) );
594
+
595
+ // Update height attribute
596
+ fireEvent.press( getByText( '300' ) );
597
+ const heightTextInput = getByDisplayValue( '300' );
598
+ fireEvent.changeText( heightTextInput, '20' );
599
+
600
+ expect( getEditorHtml() ).toMatchSnapshot();
601
+ } );
602
+
603
+ it( 'changes the height value between units', async () => {
604
+ const screen = await initializeEditor( {
605
+ initialHtml: COVER_BLOCK_CUSTOM_HEIGHT_HTML,
606
+ } );
607
+ const { getByText } = screen;
608
+
609
+ // Get block
610
+ const coverBlock = await getBlock( screen, 'Cover' );
611
+ fireEvent.press( coverBlock );
612
+
613
+ // Open block settings
614
+ await openBlockSettings( screen );
615
+
616
+ // Set the pixel unit
617
+ fireEvent.press( getByText( 'vw' ) );
618
+ fireEvent.press( getByText( 'Pixels (px)' ) );
619
+
620
+ expect( getEditorHtml() ).toMatchSnapshot();
621
+ } );
622
+
623
+ describe( 'disables the decrease button when reaching the minimum value', () => {
624
+ const testData = [
625
+ [ 'Pixels (px)', '50', '50' ],
626
+ [ 'Relative to parent font size (em)', '20', '1' ],
627
+ [ 'Relative to root font size (rem)', '20', '1' ],
628
+ [ 'Viewport width (vw)', '20', '1' ],
629
+ [ 'Viewport height (vh)', '20', '1' ],
630
+ ];
631
+
632
+ test.each( testData )(
633
+ 'for %s',
634
+ async ( unitName, value, minValue ) => {
635
+ const screen = await initializeEditor( {
636
+ initialHtml: COVER_BLOCK_CUSTOM_HEIGHT_HTML,
637
+ } );
638
+ const { getByA11yLabel, getByText } = screen;
639
+
640
+ // Get block
641
+ const coverBlock = await getBlock( screen, 'Cover' );
642
+ fireEvent.press( coverBlock );
643
+
644
+ // Open block settings
645
+ await openBlockSettings( screen );
646
+
647
+ // Set the unit name
648
+ fireEvent.press( getByText( 'vw' ) );
649
+ fireEvent.press( getByText( unitName ) );
650
+
651
+ // Update height attribute
652
+ const heightControl = getByA11yLabel( /Minimum height/ );
653
+ fireEvent.press( within( heightControl ).getByText( value ) );
654
+ const heightTextInput =
655
+ within( heightControl ).getByDisplayValue( value );
656
+ fireEvent.changeText( heightTextInput, minValue );
657
+
658
+ // The decreasing button should be disabled
659
+ fireEvent( heightControl, 'accessibilityAction', {
660
+ nativeEvent: { actionName: 'decrement' },
661
+ } );
662
+
663
+ expect( getEditorHtml() ).toMatchSnapshot();
664
+ }
665
+ );
666
+ } );
667
+ } );
@@ -8,18 +8,22 @@
8
8
  "textdomain": "default",
9
9
  "attributes": {
10
10
  "url": {
11
- "type": "string"
11
+ "type": "string",
12
+ "__experimentalRole": "content"
12
13
  },
13
14
  "caption": {
14
15
  "type": "string",
15
16
  "source": "html",
16
- "selector": "figcaption"
17
+ "selector": "figcaption",
18
+ "__experimentalRole": "content"
17
19
  },
18
20
  "type": {
19
- "type": "string"
21
+ "type": "string",
22
+ "__experimentalRole": "content"
20
23
  },
21
24
  "providerNameSlug": {
22
- "type": "string"
25
+ "type": "string",
26
+ "__experimentalRole": "content"
23
27
  },
24
28
  "allowResponsive": {
25
29
  "type": "boolean",
@@ -27,11 +31,13 @@
27
31
  },
28
32
  "responsive": {
29
33
  "type": "boolean",
30
- "default": false
34
+ "default": false,
35
+ "__experimentalRole": "content"
31
36
  },
32
37
  "previewable": {
33
38
  "type": "boolean",
34
- "default": true
39
+ "default": true,
40
+ "__experimentalRole": "content"
35
41
  }
36
42
  },
37
43
  "supports": {
@@ -39,8 +39,7 @@ jest.mock( 'react-native-modal', () => {
39
39
  } );
40
40
 
41
41
  // Mock debounce to prevent potentially belated state updates.
42
- jest.mock( 'lodash', () => ( {
43
- ...jest.requireActual( 'lodash' ),
42
+ jest.mock( '@wordpress/compose/src/utils/debounce', () => ( {
44
43
  debounce: ( fn ) => {
45
44
  fn.cancel = jest.fn();
46
45
  return fn;
@@ -32,7 +32,7 @@ import {
32
32
  /** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */
33
33
 
34
34
  /**
35
- * Template option choices for predefined columns layouts.
35
+ * The embed provider services.
36
36
  *
37
37
  * @type {WPBlockVariation[]}
38
38
  */
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { debounce } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -11,6 +6,7 @@ import {
11
6
  useBlockProps,
12
7
  store as blockEditorStore,
13
8
  } from '@wordpress/block-editor';
9
+ import { debounce } from '@wordpress/compose';
14
10
  import { useSelect } from '@wordpress/data';
15
11
  import { ToolbarGroup } from '@wordpress/components';
16
12
  import { useEffect, useRef } from '@wordpress/element';
@@ -47,6 +43,10 @@ export default function ClassicEdit( {
47
43
  onReplace,
48
44
  } ) {
49
45
  const { getMultiSelectedBlockClientIds } = useSelect( blockEditorStore );
46
+ const canRemove = useSelect(
47
+ ( select ) => select( blockEditorStore ).canRemoveBlock( clientId ),
48
+ [ clientId ]
49
+ );
50
50
  const didMount = useRef( false );
51
51
 
52
52
  useEffect( () => {
@@ -225,11 +225,13 @@ export default function ClassicEdit( {
225
225
  /* eslint-disable jsx-a11y/no-static-element-interactions */
226
226
  return (
227
227
  <>
228
- <BlockControls>
229
- <ToolbarGroup>
230
- <ConvertToBlocksButton clientId={ clientId } />
231
- </ToolbarGroup>
232
- </BlockControls>
228
+ { canRemove && (
229
+ <BlockControls>
230
+ <ToolbarGroup>
231
+ <ConvertToBlocksButton clientId={ clientId } />
232
+ </ToolbarGroup>
233
+ </BlockControls>
234
+ ) }
233
235
  <div { ...useBlockProps() }>
234
236
  <div
235
237
  key="toolbar"
@@ -659,8 +659,8 @@ const v3 = {
659
659
  attribute: 'data-link',
660
660
  },
661
661
  caption: {
662
- type: 'array',
663
- source: 'children',
662
+ type: 'string',
663
+ source: 'html',
664
664
  selector: 'figcaption',
665
665
  },
666
666
  },
@@ -779,8 +779,8 @@ const v2 = {
779
779
  attribute: 'data-link',
780
780
  },
781
781
  caption: {
782
- type: 'array',
783
- source: 'children',
782
+ type: 'string',
783
+ source: 'html',
784
784
  selector: 'figcaption',
785
785
  },
786
786
  },
@@ -0,0 +1,19 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Group block inserts block and adds a Heading block as an inner block 1`] = `
4
+ "<!-- wp:group {\\"layout\\":{\\"type\\":\\"constrained\\"}} -->
5
+ <div class=\\"wp-block-group\\"><!-- wp:heading -->
6
+ <h2></h2>
7
+ <!-- /wp:heading --></div>
8
+ <!-- /wp:group -->"
9
+ `;
10
+
11
+ exports[`Group block ungroups inner blocks 1`] = `
12
+ "<!-- wp:image -->
13
+ <figure class=\\"wp-block-image\\"><img alt=\\"\\"/></figure>
14
+ <!-- /wp:image -->
15
+
16
+ <!-- wp:spacer -->
17
+ <div style=\\"height:100px\\" aria-hidden=\\"true\\" class=\\"wp-block-spacer\\"></div>
18
+ <!-- /wp:spacer -->"
19
+ `;
@@ -0,0 +1,102 @@
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
+ const NESTED_GROUP_BLOCK = `<!-- wp:group {"layout":{"type":"constrained"}} -->
21
+ <div class="wp-block-group"><!-- wp:image -->
22
+ <figure class="wp-block-image"><img alt=""/></figure>
23
+ <!-- /wp:image -->
24
+ <!-- wp:group {"layout":{"type":"constrained"}} -->
25
+ <div class="wp-block-group"><!-- wp:spacer -->
26
+ <div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
27
+ <!-- /wp:spacer --></div>
28
+ <!-- /wp:group --></div>
29
+ <!-- /wp:group -->`;
30
+
31
+ beforeAll( () => {
32
+ // Register all core blocks
33
+ registerCoreBlocks();
34
+ } );
35
+
36
+ afterAll( () => {
37
+ // Clean up registered blocks
38
+ getBlockTypes().forEach( ( block ) => {
39
+ unregisterBlockType( block.name );
40
+ } );
41
+ } );
42
+
43
+ describe( 'Group block', () => {
44
+ it( 'inserts block and adds a Heading block as an inner block', async () => {
45
+ const screen = await initializeEditor();
46
+ const { getByTestId, getByText } = screen;
47
+
48
+ // Add block
49
+ await addBlock( screen, 'Group' );
50
+
51
+ // Get block
52
+ const groupBlock = await getBlock( screen, 'Group' );
53
+ fireEvent.press( groupBlock );
54
+
55
+ // Append a block in the Group block
56
+ const appenderButton =
57
+ within( groupBlock ).getByTestId( 'appender-button' );
58
+ fireEvent.press( appenderButton );
59
+
60
+ // Look for a block in the inserter
61
+ const blockList = getByTestId( 'InserterUI-Blocks' );
62
+
63
+ // onScroll event used to force the FlatList to render all items
64
+ fireEvent.scroll( blockList, {
65
+ nativeEvent: {
66
+ contentOffset: { y: 0, x: 0 },
67
+ contentSize: { width: 100, height: 100 },
68
+ layoutMeasurement: { width: 100, height: 100 },
69
+ },
70
+ } );
71
+
72
+ // Add a block
73
+ fireEvent.press( await waitFor( () => getByText( 'Heading' ) ) );
74
+
75
+ expect( getEditorHtml() ).toMatchSnapshot();
76
+ } );
77
+
78
+ it( 'ungroups inner blocks', async () => {
79
+ const screen = await initializeEditor( {
80
+ initialHtml: NESTED_GROUP_BLOCK,
81
+ } );
82
+ const { getByA11yLabel } = screen;
83
+
84
+ // Get block
85
+ let groupBlock = await getBlock( screen, 'Group' );
86
+ fireEvent.press( groupBlock );
87
+
88
+ // Get Ungroup button
89
+ let ungroupButton = getByA11yLabel( /Ungroup/ );
90
+ fireEvent.press( ungroupButton );
91
+
92
+ // Press Group block again
93
+ groupBlock = await getBlock( screen, 'Group', { rowIndex: 2 } );
94
+ fireEvent.press( groupBlock );
95
+
96
+ // Ungroup last block
97
+ ungroupButton = getByA11yLabel( /Ungroup/ );
98
+ fireEvent.press( ungroupButton );
99
+
100
+ expect( getEditorHtml() ).toMatchSnapshot();
101
+ } );
102
+ } );
@@ -65,6 +65,7 @@ export default function ListItemEdit( {
65
65
  const blockProps = useBlockProps( { ref: useCopy( clientId ) } );
66
66
  const innerBlocksProps = useInnerBlocksProps( blockProps, {
67
67
  allowedBlocks: [ 'core/list' ],
68
+ renderAppender: false,
68
69
  } );
69
70
  const useEnterRef = useEnter( { content, clientId } );
70
71
  const useSpaceRef = useSpace( clientId );
@@ -4,8 +4,8 @@
4
4
  import { __, sprintf } from '@wordpress/i18n';
5
5
  import { RawHTML } from '@wordpress/element';
6
6
  import { Button } from '@wordpress/components';
7
- import { getBlockType, createBlock } from '@wordpress/blocks';
8
- import { withDispatch } from '@wordpress/data';
7
+ import { createBlock } from '@wordpress/blocks';
8
+ import { withDispatch, useSelect } from '@wordpress/data';
9
9
  import {
10
10
  Warning,
11
11
  useBlockProps,
@@ -13,10 +13,21 @@ import {
13
13
  } from '@wordpress/block-editor';
14
14
  import { safeHTML } from '@wordpress/dom';
15
15
 
16
- function MissingBlockWarning( { attributes, convertToHTML } ) {
16
+ function MissingBlockWarning( { attributes, convertToHTML, clientId } ) {
17
17
  const { originalName, originalUndelimitedContent } = attributes;
18
18
  const hasContent = !! originalUndelimitedContent;
19
- const hasHTMLBlock = getBlockType( 'core/html' );
19
+ const hasHTMLBlock = useSelect(
20
+ ( select ) => {
21
+ const { canInsertBlockType, getBlockRootClientId } =
22
+ select( blockEditorStore );
23
+
24
+ return canInsertBlockType(
25
+ 'core/html',
26
+ getBlockRootClientId( clientId )
27
+ );
28
+ },
29
+ [ clientId ]
30
+ );
20
31
 
21
32
  const actions = [];
22
33
  let messageHTML;
package/src/more/edit.js CHANGED
@@ -54,7 +54,7 @@ export default function MoreEdit( {
54
54
  </InspectorControls>
55
55
  <div { ...useBlockProps() }>
56
56
  <input
57
- aria-label={ __( 'Read more link text' ) }
57
+ aria-label={ __( 'Read more link text' ) }
58
58
  type="text"
59
59
  value={ customText }
60
60
  placeholder={ DEFAULT_TEXT }