@wordpress/block-editor 7.0.3 → 7.0.4

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 (248) hide show
  1. package/build/components/block-actions/index.js +6 -5
  2. package/build/components/block-actions/index.js.map +1 -1
  3. package/build/components/block-alignment-control/use-available-alignments.js +17 -4
  4. package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
  5. package/build/components/block-inspector/index.js +1 -1
  6. package/build/components/block-inspector/index.js.map +1 -1
  7. package/build/components/block-list/block-html.js +5 -0
  8. package/build/components/block-list/block-html.js.map +1 -1
  9. package/build/components/block-list/block.native.js +2 -2
  10. package/build/components/block-list/block.native.js.map +1 -1
  11. package/build/components/block-list-appender/index.js +9 -1
  12. package/build/components/block-list-appender/index.js.map +1 -1
  13. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
  14. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  15. package/build/components/block-settings-menu-controls/index.js +10 -3
  16. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  17. package/build/components/block-switcher/block-styles-menu.js +1 -1
  18. package/build/components/block-switcher/block-styles-menu.js.map +1 -1
  19. package/build/components/block-tools/index.js +4 -1
  20. package/build/components/block-tools/index.js.map +1 -1
  21. package/build/components/block-tools/insertion-point.js +96 -7
  22. package/build/components/block-tools/insertion-point.js.map +1 -1
  23. package/build/components/border-radius-control/index.js.map +1 -1
  24. package/build/components/border-radius-control/utils.js +17 -8
  25. package/build/components/border-radius-control/utils.js.map +1 -1
  26. package/build/components/colors-gradients/control.js +17 -13
  27. package/build/components/colors-gradients/control.js.map +1 -1
  28. package/build/components/copy-handler/index.js +3 -3
  29. package/build/components/copy-handler/index.js.map +1 -1
  30. package/build/components/default-block-appender/index.js +2 -2
  31. package/build/components/default-block-appender/index.js.map +1 -1
  32. package/build/components/font-appearance-control/index.js +3 -5
  33. package/build/components/font-appearance-control/index.js.map +1 -1
  34. package/build/components/index.js +0 -18
  35. package/build/components/index.js.map +1 -1
  36. package/build/components/inserter/block-patterns-tab.js +11 -1
  37. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  38. package/build/components/inserter/hooks/use-clipboard-block.native.js +5 -4
  39. package/build/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
  40. package/build/components/inserter/preview-panel.js +1 -1
  41. package/build/components/inserter/preview-panel.js.map +1 -1
  42. package/build/components/inspector-controls/block-support-slot-container.js +28 -0
  43. package/build/components/inspector-controls/block-support-slot-container.js.map +1 -0
  44. package/build/components/inspector-controls/block-support-tools-panel.js +7 -4
  45. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  46. package/build/components/inspector-controls/fill.js +16 -1
  47. package/build/components/inspector-controls/fill.js.map +1 -1
  48. package/build/components/inspector-controls/slot.js +5 -2
  49. package/build/components/inspector-controls/slot.js.map +1 -1
  50. package/build/components/list-view/block-contents.js +1 -20
  51. package/build/components/list-view/block-contents.js.map +1 -1
  52. package/build/components/list-view/block.js +5 -36
  53. package/build/components/list-view/block.js.map +1 -1
  54. package/build/components/list-view/list-item.js +3 -2
  55. package/build/components/list-view/list-item.js.map +1 -1
  56. package/build/components/media-placeholder/index.js +26 -17
  57. package/build/components/media-placeholder/index.js.map +1 -1
  58. package/build/components/media-replace-flow/index.js +3 -2
  59. package/build/components/media-replace-flow/index.js.map +1 -1
  60. package/build/components/plain-text/index.native.js +30 -1
  61. package/build/components/plain-text/index.native.js.map +1 -1
  62. package/build/components/rich-text/embed-handler-picker.native.js +65 -0
  63. package/build/components/rich-text/embed-handler-picker.native.js.map +1 -0
  64. package/build/components/rich-text/index.js +5 -1
  65. package/build/components/rich-text/index.js.map +1 -1
  66. package/build/components/rich-text/index.native.js +41 -2
  67. package/build/components/rich-text/index.native.js.map +1 -1
  68. package/build/components/rich-text/use-paste-handler.js +28 -9
  69. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  70. package/build/components/rich-text/utils.js +22 -0
  71. package/build/components/rich-text/utils.js.map +1 -1
  72. package/build/hooks/align.js +10 -7
  73. package/build/hooks/align.js.map +1 -1
  74. package/build/hooks/anchor.js +1 -1
  75. package/build/hooks/anchor.js.map +1 -1
  76. package/build/hooks/font-family.js +93 -23
  77. package/build/hooks/font-family.js.map +1 -1
  78. package/build/hooks/style.js +6 -3
  79. package/build/hooks/style.js.map +1 -1
  80. package/build/layouts/flow.js +4 -1
  81. package/build/layouts/flow.js.map +1 -1
  82. package/build/store/reducer.js +11 -1
  83. package/build/store/reducer.js.map +1 -1
  84. package/build/store/selectors.js +1 -3
  85. package/build/store/selectors.js.map +1 -1
  86. package/build/utils/transform-styles/transforms/wrap.js +16 -0
  87. package/build/utils/transform-styles/transforms/wrap.js.map +1 -1
  88. package/build-module/components/block-actions/index.js +6 -5
  89. package/build-module/components/block-actions/index.js.map +1 -1
  90. package/build-module/components/block-alignment-control/use-available-alignments.js +17 -4
  91. package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
  92. package/build-module/components/block-inspector/index.js +1 -1
  93. package/build-module/components/block-inspector/index.js.map +1 -1
  94. package/build-module/components/block-list/block-html.js +5 -0
  95. package/build-module/components/block-list/block-html.js.map +1 -1
  96. package/build-module/components/block-list/block.native.js +2 -2
  97. package/build-module/components/block-list/block.native.js.map +1 -1
  98. package/build-module/components/block-list-appender/index.js +9 -1
  99. package/build-module/components/block-list-appender/index.js.map +1 -1
  100. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
  101. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  102. package/build-module/components/block-settings-menu-controls/index.js +10 -3
  103. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  104. package/build-module/components/block-switcher/block-styles-menu.js +1 -1
  105. package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
  106. package/build-module/components/block-tools/index.js +4 -1
  107. package/build-module/components/block-tools/index.js.map +1 -1
  108. package/build-module/components/block-tools/insertion-point.js +96 -8
  109. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  110. package/build-module/components/border-radius-control/index.js.map +1 -1
  111. package/build-module/components/border-radius-control/utils.js +16 -9
  112. package/build-module/components/border-radius-control/utils.js.map +1 -1
  113. package/build-module/components/colors-gradients/control.js +18 -14
  114. package/build-module/components/colors-gradients/control.js.map +1 -1
  115. package/build-module/components/copy-handler/index.js +3 -3
  116. package/build-module/components/copy-handler/index.js.map +1 -1
  117. package/build-module/components/default-block-appender/index.js +2 -2
  118. package/build-module/components/default-block-appender/index.js.map +1 -1
  119. package/build-module/components/font-appearance-control/index.js +3 -5
  120. package/build-module/components/font-appearance-control/index.js.map +1 -1
  121. package/build-module/components/index.js +0 -2
  122. package/build-module/components/index.js.map +1 -1
  123. package/build-module/components/inserter/block-patterns-tab.js +11 -1
  124. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  125. package/build-module/components/inserter/hooks/use-clipboard-block.native.js +5 -4
  126. package/build-module/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
  127. package/build-module/components/inserter/preview-panel.js +1 -1
  128. package/build-module/components/inserter/preview-panel.js.map +1 -1
  129. package/build-module/components/inspector-controls/block-support-slot-container.js +18 -0
  130. package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -0
  131. package/build-module/components/inspector-controls/block-support-tools-panel.js +7 -4
  132. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  133. package/build-module/components/inspector-controls/fill.js +16 -2
  134. package/build-module/components/inspector-controls/fill.js.map +1 -1
  135. package/build-module/components/inspector-controls/slot.js +4 -2
  136. package/build-module/components/inspector-controls/slot.js.map +1 -1
  137. package/build-module/components/list-view/block-contents.js +1 -18
  138. package/build-module/components/list-view/block-contents.js.map +1 -1
  139. package/build-module/components/list-view/block.js +7 -37
  140. package/build-module/components/list-view/block.js.map +1 -1
  141. package/build-module/components/list-view/list-item.js +3 -2
  142. package/build-module/components/list-view/list-item.js.map +1 -1
  143. package/build-module/components/media-placeholder/index.js +26 -17
  144. package/build-module/components/media-placeholder/index.js.map +1 -1
  145. package/build-module/components/media-replace-flow/index.js +3 -2
  146. package/build-module/components/media-replace-flow/index.js.map +1 -1
  147. package/build-module/components/plain-text/index.native.js +29 -2
  148. package/build-module/components/plain-text/index.native.js.map +1 -1
  149. package/build-module/components/rich-text/embed-handler-picker.native.js +53 -0
  150. package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -0
  151. package/build-module/components/rich-text/index.js +4 -1
  152. package/build-module/components/rich-text/index.js.map +1 -1
  153. package/build-module/components/rich-text/index.native.js +41 -3
  154. package/build-module/components/rich-text/index.native.js.map +1 -1
  155. package/build-module/components/rich-text/use-paste-handler.js +28 -9
  156. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  157. package/build-module/components/rich-text/utils.js +20 -0
  158. package/build-module/components/rich-text/utils.js.map +1 -1
  159. package/build-module/hooks/align.js +10 -7
  160. package/build-module/hooks/align.js.map +1 -1
  161. package/build-module/hooks/anchor.js +1 -1
  162. package/build-module/hooks/anchor.js.map +1 -1
  163. package/build-module/hooks/font-family.js +91 -24
  164. package/build-module/hooks/font-family.js.map +1 -1
  165. package/build-module/hooks/style.js +6 -3
  166. package/build-module/hooks/style.js.map +1 -1
  167. package/build-module/layouts/flow.js +4 -1
  168. package/build-module/layouts/flow.js.map +1 -1
  169. package/build-module/store/reducer.js +11 -1
  170. package/build-module/store/reducer.js.map +1 -1
  171. package/build-module/store/selectors.js +2 -4
  172. package/build-module/store/selectors.js.map +1 -1
  173. package/build-module/utils/transform-styles/transforms/wrap.js +16 -0
  174. package/build-module/utils/transform-styles/transforms/wrap.js.map +1 -1
  175. package/build-style/style-rtl.css +52 -76
  176. package/build-style/style.css +52 -76
  177. package/package.json +14 -14
  178. package/src/components/block-actions/index.js +5 -5
  179. package/src/components/block-alignment-control/use-available-alignments.js +18 -3
  180. package/src/components/block-inspector/index.js +1 -1
  181. package/src/components/block-list/block-html.js +5 -0
  182. package/src/components/block-list/block.native.js +2 -2
  183. package/src/components/block-list-appender/index.js +8 -0
  184. package/src/components/block-preview/README.md +1 -1
  185. package/src/components/block-preview/style.scss +0 -17
  186. package/src/components/block-settings-menu/block-settings-dropdown.js +2 -2
  187. package/src/components/block-settings-menu-controls/index.js +9 -6
  188. package/src/components/block-switcher/block-styles-menu.js +1 -1
  189. package/src/components/block-tools/index.js +5 -2
  190. package/src/components/block-tools/insertion-point.js +97 -9
  191. package/src/components/block-tools/style.scss +4 -35
  192. package/src/components/border-radius-control/index.js +1 -0
  193. package/src/components/border-radius-control/test/utils.js +216 -0
  194. package/src/components/border-radius-control/utils.js +18 -10
  195. package/src/components/color-palette/test/__snapshots__/control.js.snap +103 -72
  196. package/src/components/colors-gradients/control.js +64 -61
  197. package/src/components/colors-gradients/style.scss +8 -5
  198. package/src/components/colors-gradients/test/control.js +43 -52
  199. package/src/components/copy-handler/index.js +1 -1
  200. package/src/components/default-block-appender/index.js +2 -2
  201. package/src/components/default-block-appender/test/__snapshots__/index.js.snap +3 -3
  202. package/src/components/font-appearance-control/index.js +12 -14
  203. package/src/components/font-appearance-control/style.scss +1 -1
  204. package/src/components/index.js +0 -2
  205. package/src/components/inserter/block-patterns-tab.js +11 -4
  206. package/src/components/inserter/hooks/use-clipboard-block.native.js +3 -2
  207. package/src/components/inserter/preview-panel.js +1 -1
  208. package/src/components/inserter/style.scss +1 -2
  209. package/src/components/inspector-controls/block-support-slot-container.js +10 -0
  210. package/src/components/inspector-controls/block-support-tools-panel.js +4 -2
  211. package/src/components/inspector-controls/fill.js +23 -2
  212. package/src/components/inspector-controls/slot.js +6 -1
  213. package/src/components/link-control/style.scss +9 -5
  214. package/src/components/list-view/block-contents.js +17 -38
  215. package/src/components/list-view/block.js +6 -51
  216. package/src/components/list-view/list-item.js +5 -4
  217. package/src/components/list-view/style.scss +56 -30
  218. package/src/components/media-placeholder/index.js +24 -17
  219. package/src/components/media-replace-flow/README.md +7 -0
  220. package/src/components/media-replace-flow/index.js +2 -0
  221. package/src/components/plain-text/index.native.js +26 -4
  222. package/src/components/rich-text/embed-handler-picker.native.js +67 -0
  223. package/src/components/rich-text/index.js +12 -8
  224. package/src/components/rich-text/index.native.js +35 -1
  225. package/src/components/rich-text/use-paste-handler.js +30 -12
  226. package/src/components/rich-text/utils.js +16 -0
  227. package/src/components/skip-to-selected-block/README.md +39 -0
  228. package/src/hooks/align.js +11 -7
  229. package/src/hooks/anchor.js +2 -2
  230. package/src/hooks/font-family.js +107 -27
  231. package/src/hooks/style.js +14 -8
  232. package/src/layouts/flow.js +4 -1
  233. package/src/store/reducer.js +17 -0
  234. package/src/store/selectors.js +2 -3
  235. package/src/store/test/reducer.js +22 -0
  236. package/src/utils/transform-styles/transforms/test/wrap.js +1 -1
  237. package/src/utils/transform-styles/transforms/wrap.js +16 -0
  238. package/tsconfig.tsbuildinfo +1 -1
  239. package/build/components/list-view/block-slot.js +0 -121
  240. package/build/components/list-view/block-slot.js.map +0 -1
  241. package/build/components/list-view/editor.js +0 -35
  242. package/build/components/list-view/editor.js.map +0 -1
  243. package/build-module/components/list-view/block-slot.js +0 -96
  244. package/build-module/components/list-view/block-slot.js.map +0 -1
  245. package/build-module/components/list-view/editor.js +0 -25
  246. package/build-module/components/list-view/editor.js.map +0 -1
  247. package/src/components/list-view/block-slot.js +0 -120
  248. package/src/components/list-view/editor.js +0 -29
@@ -4,27 +4,35 @@
4
4
  import { __experimentalParseUnit as parseUnit } from '@wordpress/components';
5
5
 
6
6
  /**
7
- * Gets the item with the highest occurrence within an array
8
- * https://stackoverflow.com/a/20762713
7
+ * Gets the (non-undefined) item with the highest occurrence within an array
8
+ * Based in part on: https://stackoverflow.com/a/20762713
9
9
  *
10
- * @param {Array<any>} arr Array of items to check.
11
- * @return {any} The item with the most occurrences.
10
+ * Undefined values are always sorted to the end by `sort`, so this function
11
+ * returns the first element, to always prioritize real values over undefined
12
+ * values.
13
+ *
14
+ * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description
15
+ *
16
+ * @param {Array<any>} inputArray Array of items to check.
17
+ * @return {any} The item with the most occurrences.
12
18
  */
13
- function mode( arr ) {
19
+ export function mode( inputArray ) {
20
+ const arr = [ ...inputArray ];
14
21
  return arr
15
22
  .sort(
16
23
  ( a, b ) =>
17
- arr.filter( ( v ) => v === a ).length -
18
- arr.filter( ( v ) => v === b ).length
24
+ inputArray.filter( ( v ) => v === b ).length -
25
+ inputArray.filter( ( v ) => v === a ).length
19
26
  )
20
- .pop();
27
+ .shift();
21
28
  }
22
29
 
23
30
  /**
24
31
  * Returns the most common CSS unit in the radius values.
32
+ * Falls back to `px` as a default unit.
25
33
  *
26
34
  * @param {Object|string} values Radius values.
27
- * @return {string} Most common CSS unit in values.
35
+ * @return {string} Most common CSS unit in values. Default: `px`.
28
36
  */
29
37
  export function getAllUnit( values = {} ) {
30
38
  if ( typeof values === 'string' ) {
@@ -37,7 +45,7 @@ export function getAllUnit( values = {} ) {
37
45
  return unit;
38
46
  } );
39
47
 
40
- return mode( allUnits );
48
+ return mode( allUnits ) || 'px';
41
49
  }
42
50
 
43
51
  /**
@@ -14,6 +14,31 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
14
14
  margin-bottom: inherit;
15
15
  }
16
16
 
17
+ .emotion-4 {
18
+ display: -webkit-box;
19
+ display: -webkit-flex;
20
+ display: -ms-flexbox;
21
+ display: flex;
22
+ -webkit-align-items: normal;
23
+ -webkit-box-align: normal;
24
+ -ms-flex-align: normal;
25
+ align-items: normal;
26
+ -webkit-flex-direction: column;
27
+ -ms-flex-direction: column;
28
+ flex-direction: column;
29
+ -webkit-box-pack: justify;
30
+ -webkit-justify-content: space-between;
31
+ justify-content: space-between;
32
+ }
33
+
34
+ .emotion-4>*+*:not( marquee ) {
35
+ margin-top: calc(4px * 2);
36
+ }
37
+
38
+ .emotion-4>* {
39
+ min-height: 0;
40
+ }
41
+
17
42
  <div
18
43
  className="components-base-control block-editor-color-gradient-control emotion-0 emotion-1"
19
44
  >
@@ -21,97 +46,103 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
21
46
  className="components-base-control__field emotion-2 emotion-3"
22
47
  >
23
48
  <fieldset>
24
- <legend>
25
- <div
26
- className="block-editor-color-gradient-control__color-indicator"
27
- >
28
- <span
29
- className="components-base-control__label"
49
+ <div
50
+ className="components-flex components-h-stack components-v-stack emotion-4 emotion-5"
51
+ data-wp-c16t={true}
52
+ data-wp-component="VStack"
53
+ >
54
+ <legend>
55
+ <div
56
+ className="block-editor-color-gradient-control__color-indicator"
30
57
  >
31
- Test Color
32
58
  <span
33
- aria-label="(Color: #f00)"
34
- className="component-color-indicator"
35
- style={
36
- Object {
37
- "background": "#f00",
59
+ className="components-base-control__label"
60
+ >
61
+ Test Color
62
+ <span
63
+ aria-label="(Color: #f00)"
64
+ className="component-color-indicator"
65
+ style={
66
+ Object {
67
+ "background": "#f00",
68
+ }
38
69
  }
39
- }
40
- />
41
- </span>
42
- </div>
43
- </legend>
44
- <div
45
- className="components-circular-option-picker"
46
- >
70
+ />
71
+ </span>
72
+ </div>
73
+ </legend>
47
74
  <div
48
- className="components-circular-option-picker__swatches"
75
+ className="components-circular-option-picker"
49
76
  >
50
77
  <div
51
- className="components-circular-option-picker__option-wrapper"
78
+ className="components-circular-option-picker__swatches"
52
79
  >
53
- <button
54
- aria-describedby={null}
55
- aria-label="Color: red"
56
- aria-pressed={true}
57
- className="components-button components-circular-option-picker__option is-pressed"
58
- onBlur={[Function]}
59
- onClick={[Function]}
60
- onFocus={[Function]}
61
- onMouseDown={[Function]}
62
- onMouseEnter={[Function]}
63
- onMouseLeave={[Function]}
64
- style={
65
- Object {
66
- "backgroundColor": "#f00",
67
- "color": "#f00",
68
- }
69
- }
70
- type="button"
71
- />
72
- <svg
73
- aria-hidden={true}
74
- fill="#000"
75
- focusable={false}
76
- height={24}
77
- role="img"
78
- viewBox="0 0 24 24"
79
- width={24}
80
- xmlns="http://www.w3.org/2000/svg"
80
+ <div
81
+ className="components-circular-option-picker__option-wrapper"
81
82
  >
82
- <path
83
- d="M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
83
+ <button
84
+ aria-describedby={null}
85
+ aria-label="Color: red"
86
+ aria-pressed={true}
87
+ className="components-button components-circular-option-picker__option is-pressed"
88
+ onBlur={[Function]}
89
+ onClick={[Function]}
90
+ onFocus={[Function]}
91
+ onMouseDown={[Function]}
92
+ onMouseEnter={[Function]}
93
+ onMouseLeave={[Function]}
94
+ style={
95
+ Object {
96
+ "backgroundColor": "#f00",
97
+ "color": "#f00",
98
+ }
99
+ }
100
+ type="button"
84
101
  />
85
- </svg>
102
+ <svg
103
+ aria-hidden={true}
104
+ fill="#000"
105
+ focusable={false}
106
+ height={24}
107
+ role="img"
108
+ viewBox="0 0 24 24"
109
+ width={24}
110
+ xmlns="http://www.w3.org/2000/svg"
111
+ >
112
+ <path
113
+ d="M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
114
+ />
115
+ </svg>
116
+ </div>
86
117
  </div>
87
- </div>
88
- <div
89
- className="components-circular-option-picker__custom-clear-wrapper"
90
- >
91
118
  <div
92
- className="components-dropdown components-circular-option-picker__dropdown-link-action"
93
- tabIndex="-1"
119
+ className="components-circular-option-picker__custom-clear-wrapper"
94
120
  >
121
+ <div
122
+ className="components-dropdown components-circular-option-picker__dropdown-link-action"
123
+ tabIndex="-1"
124
+ >
125
+ <button
126
+ aria-describedby={null}
127
+ aria-expanded={false}
128
+ aria-haspopup="true"
129
+ aria-label="Custom color picker"
130
+ className="components-button is-link"
131
+ onClick={[Function]}
132
+ type="button"
133
+ >
134
+ Custom color
135
+ </button>
136
+ </div>
95
137
  <button
96
138
  aria-describedby={null}
97
- aria-expanded={false}
98
- aria-haspopup="true"
99
- aria-label="Custom color picker"
100
- className="components-button is-link"
139
+ className="components-button components-circular-option-picker__clear is-secondary is-small"
101
140
  onClick={[Function]}
102
141
  type="button"
103
142
  >
104
- Custom color
143
+ Clear
105
144
  </button>
106
145
  </div>
107
- <button
108
- aria-describedby={null}
109
- className="components-button components-circular-option-picker__clear is-secondary is-small"
110
- onClick={[Function]}
111
- type="button"
112
- >
113
- Clear
114
- </button>
115
146
  </div>
116
147
  </div>
117
148
  </fieldset>
@@ -10,8 +10,9 @@ import { every, isEmpty } from 'lodash';
10
10
  import { useState } from '@wordpress/element';
11
11
  import {
12
12
  BaseControl,
13
- Button,
14
- ButtonGroup,
13
+ __experimentalVStack as VStack,
14
+ __experimentalToggleGroupControl as ToggleGroupControl,
15
+ __experimentalToggleGroupControlOption as ToggleGroupControlOption,
15
16
  ColorIndicator,
16
17
  ColorPalette,
17
18
  GradientPicker,
@@ -110,66 +111,68 @@ function ColorGradientControlInner( {
110
111
  ) }
111
112
  >
112
113
  <fieldset>
113
- <legend>
114
- <div className="block-editor-color-gradient-control__color-indicator">
115
- <BaseControl.VisualLabel>
116
- <VisualLabel
117
- currentTab={ currentTab }
118
- label={ label }
119
- colorValue={ colorValue }
120
- gradientValue={ gradientValue }
121
- />
122
- </BaseControl.VisualLabel>
123
- </div>
124
- </legend>
125
- { canChooseAColor && canChooseAGradient && (
126
- <ButtonGroup className="block-editor-color-gradient-control__button-tabs">
127
- <Button
128
- isSmall
129
- isPressed={ currentTab === 'color' }
130
- onClick={ () => setCurrentTab( 'color' ) }
131
- >
132
- { __( 'Solid' ) }
133
- </Button>
134
- <Button
135
- isSmall
136
- isPressed={ currentTab === 'gradient' }
137
- onClick={ () => setCurrentTab( 'gradient' ) }
114
+ <VStack space={ 3 }>
115
+ <legend>
116
+ <div className="block-editor-color-gradient-control__color-indicator">
117
+ <BaseControl.VisualLabel>
118
+ <VisualLabel
119
+ currentTab={ currentTab }
120
+ label={ label }
121
+ colorValue={ colorValue }
122
+ gradientValue={ gradientValue }
123
+ />
124
+ </BaseControl.VisualLabel>
125
+ </div>
126
+ </legend>
127
+ { canChooseAColor && canChooseAGradient && (
128
+ <ToggleGroupControl
129
+ value={ currentTab }
130
+ onChange={ setCurrentTab }
131
+ label={ __( 'Select color type' ) }
132
+ hideLabelFromVision
133
+ isBlock
138
134
  >
139
- { __( 'Gradient' ) }
140
- </Button>
141
- </ButtonGroup>
142
- ) }
143
- { ( currentTab === 'color' || ! canChooseAGradient ) && (
144
- <ColorPalette
145
- value={ colorValue }
146
- onChange={
147
- canChooseAGradient
148
- ? ( newColor ) => {
149
- onColorChange( newColor );
150
- onGradientChange();
151
- }
152
- : onColorChange
153
- }
154
- { ...{ colors, disableCustomColors } }
155
- clearable={ clearable }
156
- />
157
- ) }
158
- { ( currentTab === 'gradient' || ! canChooseAColor ) && (
159
- <GradientPicker
160
- value={ gradientValue }
161
- onChange={
162
- canChooseAColor
163
- ? ( newGradient ) => {
164
- onGradientChange( newGradient );
165
- onColorChange();
166
- }
167
- : onGradientChange
168
- }
169
- { ...{ gradients, disableCustomGradients } }
170
- clearable={ clearable }
171
- />
172
- ) }
135
+ <ToggleGroupControlOption
136
+ value="color"
137
+ label={ __( 'Solid' ) }
138
+ />
139
+ <ToggleGroupControlOption
140
+ value="gradient"
141
+ label={ __( 'Gradient' ) }
142
+ />
143
+ </ToggleGroupControl>
144
+ ) }
145
+ { ( currentTab === 'color' || ! canChooseAGradient ) && (
146
+ <ColorPalette
147
+ value={ colorValue }
148
+ onChange={
149
+ canChooseAGradient
150
+ ? ( newColor ) => {
151
+ onColorChange( newColor );
152
+ onGradientChange();
153
+ }
154
+ : onColorChange
155
+ }
156
+ { ...{ colors, disableCustomColors } }
157
+ clearable={ clearable }
158
+ />
159
+ ) }
160
+ { ( currentTab === 'gradient' || ! canChooseAColor ) && (
161
+ <GradientPicker
162
+ value={ gradientValue }
163
+ onChange={
164
+ canChooseAColor
165
+ ? ( newGradient ) => {
166
+ onGradientChange( newGradient );
167
+ onColorChange();
168
+ }
169
+ : onGradientChange
170
+ }
171
+ { ...{ gradients, disableCustomGradients } }
172
+ clearable={ clearable }
173
+ />
174
+ ) }
175
+ </VStack>
173
176
  </fieldset>
174
177
  </BaseControl>
175
178
  );
@@ -2,11 +2,6 @@
2
2
  .block-editor-color-gradient-control__color-indicator {
3
3
  margin-bottom: $grid-unit-15;
4
4
  }
5
-
6
- .block-editor-color-gradient-control__button-tabs {
7
- display: block;
8
- margin-bottom: $grid-unit-15;
9
- }
10
5
  }
11
6
 
12
7
  .block-editor-panel-color-gradient-settings {
@@ -45,4 +40,12 @@
45
40
  margin-right: 0;
46
41
  }
47
42
  }
43
+
44
+
45
+ // This shouldn't be needed but there's a rule in the inspector controls
46
+ // overriding this causing too much spacing.
47
+ // That generic rule should ideally be removed.
48
+ .block-editor-block-inspector & .components-base-control {
49
+ margin-bottom: inherit;
50
+ }
48
51
  }
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
+ import { render, screen } from '@testing-library/react';
4
5
  import { create, act } from 'react-test-renderer';
5
6
  import { noop } from 'lodash';
6
7
 
@@ -27,67 +28,57 @@ const getButtonWithAriaLabelStartPredicate = ( ariaLabelStart ) => (
27
28
  );
28
29
  };
29
30
 
30
- const colorTabButtonPredicate = getButtonWithTestPredicate( 'Solid' );
31
- const gradientTabButtonPredicate = getButtonWithTestPredicate( 'Gradient' );
31
+ const getTabWithTestPredicate = ( text ) => ( element ) => {
32
+ return (
33
+ element.type === 'button' &&
34
+ element.props[ 'aria-label' ] &&
35
+ element.props[ 'aria-label' ] === text
36
+ );
37
+ };
38
+
39
+ const colorTabButtonPredicate = getTabWithTestPredicate( 'Solid' );
40
+ const gradientTabButtonPredicate = getTabWithTestPredicate( 'Gradient' );
32
41
 
33
42
  describe( 'ColorPaletteControl', () => {
34
43
  it( 'renders tabs if it is possible to select a color and a gradient rendering a color picker at the start', async () => {
35
- let wrapper;
36
-
37
- await act( async () => {
38
- wrapper = create(
39
- <ColorGradientControl
40
- label="Test Color Gradient"
41
- colorValue="#f00"
42
- colors={ [
43
- { color: '#f00', name: 'red' },
44
- { color: '#0f0', name: 'green' },
45
- ] }
46
- gradients={ [
47
- {
48
- gradient:
49
- 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%',
50
- name: 'Vivid cyan blue to vivid purple',
51
- slug: 'vivid-cyan-blue-to-vivid-purple',
52
- },
53
- {
54
- gradient:
55
- 'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)',
56
- name: 'Light green cyan to vivid green cyan',
57
- slug: 'light-green-cyan-to-vivid-green-cyan',
58
- },
59
- ] }
60
- disableCustomColors={ false }
61
- disableCustomGradients={ false }
62
- onColorChange={ noop }
63
- onGradientChange={ noop }
64
- />
65
- );
66
- } );
44
+ render(
45
+ <ColorGradientControl
46
+ label="Test Color Gradient"
47
+ colorValue="#f00"
48
+ colors={ [
49
+ { color: '#f00', name: 'red' },
50
+ { color: '#0f0', name: 'green' },
51
+ ] }
52
+ gradients={ [
53
+ {
54
+ gradient:
55
+ 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%',
56
+ name: 'Vivid cyan blue to vivid purple',
57
+ slug: 'vivid-cyan-blue-to-vivid-purple',
58
+ },
59
+ {
60
+ gradient:
61
+ 'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)',
62
+ name: 'Light green cyan to vivid green cyan',
63
+ slug: 'light-green-cyan-to-vivid-green-cyan',
64
+ },
65
+ ] }
66
+ disableCustomColors={ false }
67
+ disableCustomGradients={ false }
68
+ onColorChange={ noop }
69
+ onGradientChange={ noop }
70
+ />
71
+ );
67
72
 
68
73
  // Is showing the two tab buttons.
69
- expect( wrapper.root.findAll( colorTabButtonPredicate ) ).toHaveLength(
70
- 1
71
- );
72
- expect(
73
- wrapper.root.findAll( gradientTabButtonPredicate )
74
- ).toHaveLength( 1 );
74
+ expect( screen.queryByLabelText( 'Solid' ) ).toBeInTheDocument();
75
+ expect( screen.queryByLabelText( 'Gradient' ) ).toBeInTheDocument();
75
76
 
76
77
  // Is showing the two predefined Colors.
77
- expect(
78
- wrapper.root.findAll(
79
- ( element ) =>
80
- element.type === 'button' &&
81
- element.props &&
82
- element.props[ 'aria-label' ] &&
83
- element.props[ 'aria-label' ].startsWith( 'Color:' )
84
- )
85
- ).toHaveLength( 2 );
78
+ expect( screen.getAllByLabelText( /^Color:/ ) ).toHaveLength( 2 );
86
79
 
87
80
  // Is showing the custom color picker.
88
- expect(
89
- wrapper.root.findAll( getButtonWithTestPredicate( 'Custom color' ) )
90
- ).toHaveLength( 1 );
81
+ expect( screen.queryByText( 'Custom color' ) ).toBeInTheDocument();
91
82
  } );
92
83
 
93
84
  it( 'renders the color picker and does not render tabs if it is only possible to select a color', async () => {
@@ -31,7 +31,7 @@ export function useNotifyCopy() {
31
31
  let notice = '';
32
32
  if ( selectedBlockClientIds.length === 1 ) {
33
33
  const clientId = selectedBlockClientIds[ 0 ];
34
- const { title } = getBlockType( getBlockName( clientId ) );
34
+ const title = getBlockType( getBlockName( clientId ) )?.title;
35
35
  notice =
36
36
  eventType === 'copy'
37
37
  ? sprintf(
@@ -59,8 +59,8 @@ export function DefaultBlockAppender( {
59
59
  // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
60
60
  role="button"
61
61
  aria-label={ __( 'Add block' ) }
62
- // The wp-block className is important for editor styles.
63
- className="wp-block block-editor-default-block-appender__content"
62
+ // A wrapping container for this one already has the wp-block className.
63
+ className="block-editor-default-block-appender__content"
64
64
  onFocus={ onAppend }
65
65
  >
66
66
  { showPrompt ? value : ZWNBSP }
@@ -7,7 +7,7 @@ exports[`DefaultBlockAppender should append a default block when input focused 1
7
7
  >
8
8
  <p
9
9
  aria-label="Add block"
10
- className="wp-block block-editor-default-block-appender__content"
10
+ className="block-editor-default-block-appender__content"
11
11
  contentEditable={true}
12
12
  onFocus={
13
13
  [MockFunction] {
@@ -43,7 +43,7 @@ exports[`DefaultBlockAppender should match snapshot 1`] = `
43
43
  >
44
44
  <p
45
45
  aria-label="Add block"
46
- className="wp-block block-editor-default-block-appender__content"
46
+ className="block-editor-default-block-appender__content"
47
47
  contentEditable={true}
48
48
  onFocus={[MockFunction]}
49
49
  role="button"
@@ -67,7 +67,7 @@ exports[`DefaultBlockAppender should optionally show without prompt 1`] = `
67
67
  >
68
68
  <p
69
69
  aria-label="Add block"
70
- className="wp-block block-editor-default-block-appender__content"
70
+ className="block-editor-default-block-appender__content"
71
71
  contentEditable={true}
72
72
  onFocus={[MockFunction]}
73
73
  role="button"
@@ -195,19 +195,17 @@ export default function FontAppearanceControl( props ) {
195
195
  };
196
196
 
197
197
  return (
198
- <fieldset className="components-font-appearance-control">
199
- { hasStylesOrWeights && (
200
- <CustomSelectControl
201
- className="components-font-appearance-control__select"
202
- label={ getLabel() }
203
- describedBy={ getDescribedBy() }
204
- options={ selectOptions }
205
- value={ currentSelection }
206
- onChange={ ( { selectedItem } ) =>
207
- onChange( selectedItem.style )
208
- }
209
- />
210
- ) }
211
- </fieldset>
198
+ hasStylesOrWeights && (
199
+ <CustomSelectControl
200
+ className="components-font-appearance-control"
201
+ label={ getLabel() }
202
+ describedBy={ getDescribedBy() }
203
+ options={ selectOptions }
204
+ value={ currentSelection }
205
+ onChange={ ( { selectedItem } ) =>
206
+ onChange( selectedItem.style )
207
+ }
208
+ />
209
+ )
212
210
  );
213
211
  }
@@ -1,4 +1,4 @@
1
- .components-font-appearance-control__select {
1
+ .components-font-appearance-control {
2
2
  margin-bottom: 24px;
3
3
 
4
4
  ul {
@@ -70,8 +70,6 @@ export { default as __experimentalLinkControlSearchResults } from './link-contro
70
70
  export { default as __experimentalLinkControlSearchItem } from './link-control/search-item';
71
71
  export { default as LineHeightControl } from './line-height-control';
72
72
  export { default as __experimentalListView } from './list-view';
73
- export { ListViewBlockFill as __experimentalListViewBlockFill } from './list-view/block-slot';
74
- export { default as __experimentalListViewEditor } from './list-view/editor';
75
73
  export { default as MediaReplaceFlow } from './media-replace-flow';
76
74
  export { default as MediaPlaceholder } from './media-placeholder';
77
75
  export { default as MediaUpload } from './media-upload';
@@ -31,11 +31,18 @@ function BlockPatternsCategory( {
31
31
  // Remove any empty categories
32
32
  const populatedCategories = useMemo(
33
33
  () =>
34
- allCategories.filter( ( category ) =>
35
- allPatterns.some( ( pattern ) =>
36
- pattern.categories?.includes( category.name )
34
+ allCategories
35
+ .filter( ( category ) =>
36
+ allPatterns.some( ( pattern ) =>
37
+ pattern.categories?.includes( category.name )
38
+ )
37
39
  )
38
- ),
40
+ .sort( ( { name: currentName }, { name: nextName } ) => {
41
+ if ( ! [ currentName, nextName ].includes( 'featured' ) ) {
42
+ return 0;
43
+ }
44
+ return currentName === 'featured' ? -1 : 1;
45
+ } ),
39
46
  [ allPatterns, allCategories ]
40
47
  );
41
48