@wordpress/block-editor 9.4.0 → 9.5.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 (234) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -8
  3. package/build/components/block-list/block-invalid-warning.native.js +54 -6
  4. package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
  5. package/build/components/block-list/block.js +2 -2
  6. package/build/components/block-list/block.js.map +1 -1
  7. package/build/components/block-list/block.native.js +2 -1
  8. package/build/components/block-list/block.native.js.map +1 -1
  9. package/build/components/block-list/index.native.js +4 -3
  10. package/build/components/block-list/index.native.js.map +1 -1
  11. package/build/components/block-list/layout.js +20 -5
  12. package/build/components/block-list/layout.js.map +1 -1
  13. package/build/components/block-list/use-block-props/use-block-class-names.js +5 -2
  14. package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  15. package/build/components/block-lock/modal.js +35 -5
  16. package/build/components/block-lock/modal.js.map +1 -1
  17. package/build/components/block-pattern-setup/index.js +5 -17
  18. package/build/components/block-pattern-setup/index.js.map +1 -1
  19. package/build/components/block-popover/inbetween.js +1 -1
  20. package/build/components/block-popover/inbetween.js.map +1 -1
  21. package/build/components/block-popover/index.js +1 -1
  22. package/build/components/block-popover/index.js.map +1 -1
  23. package/build/components/block-settings-menu/block-mode-toggle.js +1 -1
  24. package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  25. package/build/components/block-settings-menu/block-settings-dropdown.js +4 -1
  26. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  27. package/build/components/block-styles/preview.native.js +3 -1
  28. package/build/components/block-styles/preview.native.js.map +1 -1
  29. package/build/components/block-switcher/index.js +7 -1
  30. package/build/components/block-switcher/index.js.map +1 -1
  31. package/build/components/block-title/index.js +8 -2
  32. package/build/components/block-title/index.js.map +1 -1
  33. package/build/components/block-title/use-block-display-title.js +12 -5
  34. package/build/components/block-title/use-block-display-title.js.map +1 -1
  35. package/build/components/block-tools/block-contextual-toolbar.js +1 -1
  36. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  37. package/build/components/border-radius-control/index.js +2 -0
  38. package/build/components/border-radius-control/index.js.map +1 -1
  39. package/build/components/colors/with-colors.js +1 -1
  40. package/build/components/colors/with-colors.js.map +1 -1
  41. package/build/components/colors-gradients/control.js +45 -39
  42. package/build/components/colors-gradients/control.js.map +1 -1
  43. package/build/components/date-format-picker/index.js +1 -1
  44. package/build/components/date-format-picker/index.js.map +1 -1
  45. package/build/components/iframe/index.js +19 -6
  46. package/build/components/iframe/index.js.map +1 -1
  47. package/build/components/link-control/index.js +1 -1
  48. package/build/components/link-control/index.js.map +1 -1
  49. package/build/components/list-view/block-select-button.js +15 -7
  50. package/build/components/list-view/block-select-button.js.map +1 -1
  51. package/build/components/list-view/drop-indicator.js +1 -1
  52. package/build/components/list-view/drop-indicator.js.map +1 -1
  53. package/build/components/media-placeholder/index.js +13 -2
  54. package/build/components/media-placeholder/index.js.map +1 -1
  55. package/build/components/media-replace-flow/index.js +3 -6
  56. package/build/components/media-replace-flow/index.js.map +1 -1
  57. package/build/components/url-popover/index.js +2 -1
  58. package/build/components/url-popover/index.js.map +1 -1
  59. package/build/components/writing-flow/use-arrow-nav.js +34 -2
  60. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  61. package/build/components/writing-flow/use-multi-selection.js +3 -47
  62. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  63. package/build/components/writing-flow/use-selection-observer.js +1 -3
  64. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  65. package/build/hooks/color.js +2 -4
  66. package/build/hooks/color.js.map +1 -1
  67. package/build/hooks/index.js +8 -0
  68. package/build/hooks/index.js.map +1 -1
  69. package/build/hooks/layout.js +41 -14
  70. package/build/hooks/layout.js.map +1 -1
  71. package/build/hooks/utils.js +5 -3
  72. package/build/hooks/utils.js.map +1 -1
  73. package/build/index.js +7 -0
  74. package/build/index.js.map +1 -1
  75. package/build/layouts/flex.js +40 -36
  76. package/build/layouts/flex.js.map +1 -1
  77. package/build/layouts/flow.js +10 -35
  78. package/build/layouts/flow.js.map +1 -1
  79. package/build/layouts/utils.js +35 -3
  80. package/build/layouts/utils.js.map +1 -1
  81. package/build/store/actions.js +15 -18
  82. package/build/store/actions.js.map +1 -1
  83. package/build/store/index.js +0 -4
  84. package/build/store/index.js.map +1 -1
  85. package/build/store/reducer.js +5 -3
  86. package/build/store/reducer.js.map +1 -1
  87. package/build/store/selectors.js +3 -3
  88. package/build/store/selectors.js.map +1 -1
  89. package/build-module/components/block-list/block-invalid-warning.native.js +50 -6
  90. package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
  91. package/build-module/components/block-list/block.js +2 -2
  92. package/build-module/components/block-list/block.js.map +1 -1
  93. package/build-module/components/block-list/block.native.js +2 -1
  94. package/build-module/components/block-list/block.native.js.map +1 -1
  95. package/build-module/components/block-list/index.native.js +3 -1
  96. package/build-module/components/block-list/index.native.js.map +1 -1
  97. package/build-module/components/block-list/layout.js +19 -4
  98. package/build-module/components/block-list/layout.js.map +1 -1
  99. package/build-module/components/block-list/use-block-props/use-block-class-names.js +5 -2
  100. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  101. package/build-module/components/block-lock/modal.js +37 -6
  102. package/build-module/components/block-lock/modal.js.map +1 -1
  103. package/build-module/components/block-pattern-setup/index.js +6 -18
  104. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  105. package/build-module/components/block-popover/inbetween.js +1 -1
  106. package/build-module/components/block-popover/inbetween.js.map +1 -1
  107. package/build-module/components/block-popover/index.js +1 -1
  108. package/build-module/components/block-popover/index.js.map +1 -1
  109. package/build-module/components/block-settings-menu/block-mode-toggle.js +1 -1
  110. package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
  111. package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -1
  112. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  113. package/build-module/components/block-styles/preview.native.js +3 -2
  114. package/build-module/components/block-styles/preview.native.js.map +1 -1
  115. package/build-module/components/block-switcher/index.js +7 -1
  116. package/build-module/components/block-switcher/index.js.map +1 -1
  117. package/build-module/components/block-title/index.js +8 -2
  118. package/build-module/components/block-title/index.js.map +1 -1
  119. package/build-module/components/block-title/use-block-display-title.js +12 -5
  120. package/build-module/components/block-title/use-block-display-title.js.map +1 -1
  121. package/build-module/components/block-tools/block-contextual-toolbar.js +1 -1
  122. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  123. package/build-module/components/border-radius-control/index.js +2 -0
  124. package/build-module/components/border-radius-control/index.js.map +1 -1
  125. package/build-module/components/colors/with-colors.js +2 -2
  126. package/build-module/components/colors/with-colors.js.map +1 -1
  127. package/build-module/components/colors-gradients/control.js +46 -40
  128. package/build-module/components/colors-gradients/control.js.map +1 -1
  129. package/build-module/components/date-format-picker/index.js +1 -1
  130. package/build-module/components/date-format-picker/index.js.map +1 -1
  131. package/build-module/components/iframe/index.js +19 -6
  132. package/build-module/components/iframe/index.js.map +1 -1
  133. package/build-module/components/link-control/index.js +1 -1
  134. package/build-module/components/link-control/index.js.map +1 -1
  135. package/build-module/components/list-view/block-select-button.js +16 -8
  136. package/build-module/components/list-view/block-select-button.js.map +1 -1
  137. package/build-module/components/list-view/drop-indicator.js +1 -1
  138. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  139. package/build-module/components/media-placeholder/index.js +13 -2
  140. package/build-module/components/media-placeholder/index.js.map +1 -1
  141. package/build-module/components/media-replace-flow/index.js +4 -7
  142. package/build-module/components/media-replace-flow/index.js.map +1 -1
  143. package/build-module/components/url-popover/index.js +2 -1
  144. package/build-module/components/url-popover/index.js.map +1 -1
  145. package/build-module/components/writing-flow/use-arrow-nav.js +35 -3
  146. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  147. package/build-module/components/writing-flow/use-multi-selection.js +3 -45
  148. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  149. package/build-module/components/writing-flow/use-selection-observer.js +1 -3
  150. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  151. package/build-module/hooks/color.js +2 -3
  152. package/build-module/hooks/color.js.map +1 -1
  153. package/build-module/hooks/index.js +1 -0
  154. package/build-module/hooks/index.js.map +1 -1
  155. package/build-module/hooks/layout.js +42 -15
  156. package/build-module/hooks/layout.js.map +1 -1
  157. package/build-module/hooks/utils.js +5 -2
  158. package/build-module/hooks/utils.js.map +1 -1
  159. package/build-module/index.js +1 -1
  160. package/build-module/index.js.map +1 -1
  161. package/build-module/layouts/flex.js +41 -33
  162. package/build-module/layouts/flex.js.map +1 -1
  163. package/build-module/layouts/flow.js +11 -36
  164. package/build-module/layouts/flow.js.map +1 -1
  165. package/build-module/layouts/utils.js +33 -3
  166. package/build-module/layouts/utils.js.map +1 -1
  167. package/build-module/store/actions.js +9 -10
  168. package/build-module/store/actions.js.map +1 -1
  169. package/build-module/store/index.js +0 -4
  170. package/build-module/store/index.js.map +1 -1
  171. package/build-module/store/reducer.js +5 -2
  172. package/build-module/store/reducer.js.map +1 -1
  173. package/build-module/store/selectors.js +4 -4
  174. package/build-module/store/selectors.js.map +1 -1
  175. package/build-style/style-rtl.css +36 -10
  176. package/build-style/style.css +36 -10
  177. package/package.json +28 -28
  178. package/src/components/block-list/block-invalid-warning.native.js +42 -7
  179. package/src/components/block-list/block.js +2 -2
  180. package/src/components/block-list/block.native.js +1 -0
  181. package/src/components/block-list/index.native.js +1 -1
  182. package/src/components/block-list/layout.js +15 -3
  183. package/src/components/block-list/style.scss +1 -1
  184. package/src/components/block-list/use-block-props/use-block-class-names.js +5 -1
  185. package/src/components/block-lock/modal.js +42 -4
  186. package/src/components/block-lock/style.scss +10 -0
  187. package/src/components/block-pattern-setup/index.js +3 -15
  188. package/src/components/block-pattern-setup/style.scss +4 -2
  189. package/src/components/block-popover/inbetween.js +1 -1
  190. package/src/components/block-popover/index.js +1 -1
  191. package/src/components/block-settings-menu/block-mode-toggle.js +1 -0
  192. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
  193. package/src/components/block-styles/preview.native.js +3 -2
  194. package/src/components/block-switcher/index.js +7 -1
  195. package/src/components/block-title/index.js +3 -2
  196. package/src/components/block-title/use-block-display-title.js +11 -5
  197. package/src/components/block-tools/block-contextual-toolbar.js +3 -1
  198. package/src/components/border-radius-control/index.js +2 -0
  199. package/src/components/colors/with-colors.js +2 -2
  200. package/src/components/colors-gradients/control.js +77 -65
  201. package/src/components/colors-gradients/style.scss +4 -0
  202. package/src/components/colors-gradients/test/control.js +16 -23
  203. package/src/components/date-format-picker/index.js +1 -0
  204. package/src/components/iframe/index.js +25 -6
  205. package/src/components/inserter/style.scss +1 -1
  206. package/src/components/link-control/index.js +1 -0
  207. package/src/components/link-control/test/index.js +6 -4
  208. package/src/components/list-view/block-select-button.js +29 -14
  209. package/src/components/list-view/drop-indicator.js +1 -1
  210. package/src/components/list-view/style.scss +18 -4
  211. package/src/components/media-placeholder/index.js +19 -0
  212. package/src/components/media-replace-flow/index.js +3 -6
  213. package/src/components/media-replace-flow/test/index.js +14 -4
  214. package/src/components/url-popover/index.js +1 -0
  215. package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -0
  216. package/src/components/writing-flow/use-arrow-nav.js +32 -1
  217. package/src/components/writing-flow/use-multi-selection.js +1 -48
  218. package/src/components/writing-flow/use-selection-observer.js +2 -3
  219. package/src/hooks/color.js +10 -3
  220. package/src/hooks/index.js +1 -0
  221. package/src/hooks/layout.js +46 -20
  222. package/src/hooks/utils.js +7 -3
  223. package/src/index.js +1 -0
  224. package/src/layouts/flex.js +47 -41
  225. package/src/layouts/flow.js +14 -35
  226. package/src/layouts/test/flex.js +21 -0
  227. package/src/layouts/test/flow.js +21 -0
  228. package/src/layouts/test/utils.js +138 -0
  229. package/src/layouts/utils.js +44 -3
  230. package/src/store/actions.js +10 -11
  231. package/src/store/index.js +0 -4
  232. package/src/store/reducer.js +3 -2
  233. package/src/store/selectors.js +3 -4
  234. package/tsconfig.json +2 -1
@@ -11,7 +11,7 @@ import {
11
11
  } from '@wordpress/components';
12
12
 
13
13
  import { useState } from '@wordpress/element';
14
- import { useInstanceId, useResizeObserver } from '@wordpress/compose';
14
+ import { useInstanceId } from '@wordpress/compose';
15
15
  import { __ } from '@wordpress/i18n';
16
16
 
17
17
  /**
@@ -28,7 +28,6 @@ const SetupContent = ( {
28
28
  activeSlide,
29
29
  patterns,
30
30
  onBlockPatternSelect,
31
- height,
32
31
  } ) => {
33
32
  const composite = useCompositeState();
34
33
  const containerClass = 'block-editor-block-pattern-setup__container';
@@ -39,10 +38,7 @@ const SetupContent = ( {
39
38
  [ activeSlide + 1, 'next-slide' ],
40
39
  ] );
41
40
  return (
42
- <div
43
- className="block-editor-block-pattern-setup__carousel"
44
- style={ { height } }
45
- >
41
+ <div className="block-editor-block-pattern-setup__carousel">
46
42
  <div className={ containerClass }>
47
43
  <ul className="carousel-container">
48
44
  { patterns.map( ( pattern, index ) => (
@@ -50,7 +46,6 @@ const SetupContent = ( {
50
46
  className={ slideClass.get( index ) || '' }
51
47
  key={ pattern.name }
52
48
  pattern={ pattern }
53
- minHeight={ height }
54
49
  />
55
50
  ) ) }
56
51
  </ul>
@@ -59,10 +54,7 @@ const SetupContent = ( {
59
54
  );
60
55
  }
61
56
  return (
62
- <div
63
- style={ { height } }
64
- className="block-editor-block-pattern-setup__grid"
65
- >
57
+ <div className="block-editor-block-pattern-setup__grid">
66
58
  <Composite
67
59
  { ...composite }
68
60
  role="listbox"
@@ -151,8 +143,6 @@ const BlockPatternSetup = ( {
151
143
  const [ activeSlide, setActiveSlide ] = useState( 0 );
152
144
  const { replaceBlock } = useDispatch( blockEditorStore );
153
145
  const patterns = usePatternsSetup( clientId, blockName, filterPatternsFn );
154
- const [ contentResizeListener, { height: contentHeight } ] =
155
- useResizeObserver();
156
146
 
157
147
  if ( ! patterns?.length ) {
158
148
  return null;
@@ -166,7 +156,6 @@ const BlockPatternSetup = ( {
166
156
  onBlockPatternSelect || onBlockPatternSelectDefault;
167
157
  return (
168
158
  <>
169
- { contentResizeListener }
170
159
  <div
171
160
  className={ `block-editor-block-pattern-setup view-mode-${ viewMode }` }
172
161
  >
@@ -175,7 +164,6 @@ const BlockPatternSetup = ( {
175
164
  activeSlide={ activeSlide }
176
165
  patterns={ patterns }
177
166
  onBlockPatternSelect={ onPatternSelectCallback }
178
- height={ contentHeight - 2 * 60 }
179
167
  />
180
168
  <SetupToolbar
181
169
  viewMode={ viewMode }
@@ -17,6 +17,8 @@
17
17
  display: block;
18
18
  width: 100%;
19
19
  padding: $grid-unit-40;
20
+ padding-bottom: 0;
21
+ padding-top: 0;
20
22
  column-count: 2;
21
23
 
22
24
  @include break-huge() {
@@ -53,8 +55,9 @@
53
55
  text-align: left;
54
56
  margin: 0;
55
57
  color: $gray-900;
58
+ position: absolute;
59
+ bottom: 0;
56
60
  // Block UI appearance.
57
- border-radius: $radius-block-ui $radius-block-ui 0 0;
58
61
  background-color: $white;
59
62
  display: flex;
60
63
  flex-direction: row;
@@ -129,5 +132,4 @@
129
132
  .block-editor-block-pattern-setup__carousel,
130
133
  .block-editor-block-pattern-setup__grid {
131
134
  width: 100%;
132
- overflow-y: auto;
133
135
  }
@@ -172,7 +172,7 @@ function BlockPopoverInbetween( {
172
172
  getAnchorRect={ getAnchorRect }
173
173
  focusOnMount={ false }
174
174
  // Render in the old slot if needed for backward compatibility,
175
- // otherwise render in place (not in the the default popover slot).
175
+ // otherwise render in place (not in the default popover slot).
176
176
  __unstableSlotName={ __unstablePopoverSlot || null }
177
177
  // Forces a remount of the popover when its position changes
178
178
  // This makes sure the popover doesn't animate from its previous position.
@@ -57,7 +57,7 @@ export default function BlockPopover( {
57
57
  focusOnMount={ false }
58
58
  anchorRef={ anchorRef }
59
59
  // Render in the old slot if needed for backward compatibility,
60
- // otherwise render in place (not in the the default popover slot).
60
+ // otherwise render in place (not in the default popover slot).
61
61
  __unstableSlotName={ __unstablePopoverSlot || null }
62
62
  // Observe movement for block animations (especially horizontal).
63
63
  __unstableObserveElement={ selectedElement }
@@ -22,6 +22,7 @@ export function BlockModeToggle( {
22
22
  isCodeEditingEnabled = true,
23
23
  } ) {
24
24
  if (
25
+ ! blockType ||
25
26
  ! hasBlockSupport( blockType, 'html', true ) ||
26
27
  ! isCodeEditingEnabled
27
28
  ) {
@@ -125,7 +125,10 @@ export function BlockSettingsDropdown( {
125
125
  [ __experimentalSelectBlock ]
126
126
  );
127
127
 
128
- const blockTitle = useBlockDisplayTitle( firstBlockClientId, 25 );
128
+ const blockTitle = useBlockDisplayTitle( {
129
+ clientId: firstBlockClientId,
130
+ maximumLength: 25,
131
+ } );
129
132
 
130
133
  const updateSelectionAfterRemove = useCallback(
131
134
  __experimentalSelectBlock
@@ -8,8 +8,9 @@ import {
8
8
  Dimensions,
9
9
  Animated,
10
10
  Easing,
11
- Image,
12
11
  } from 'react-native';
12
+ import FastImage from 'react-native-fast-image';
13
+
13
14
  /**
14
15
  * WordPress dependencies
15
16
  */
@@ -90,7 +91,7 @@ function StylePreview( { onPress, isActive, style, url } ) {
90
91
  <View style={ styles.imageWrapper }>
91
92
  { isActive &&
92
93
  getOutline( [ styles.outline, innerOutlineStyle ] ) }
93
- <Image
94
+ <FastImage
94
95
  style={ [ styles.image, styles[ name ] ] }
95
96
  source={ { uri: url } }
96
97
  />
@@ -98,8 +98,14 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
98
98
  // Pattern transformation through the `Patterns` API.
99
99
  const onPatternTransform = ( transformedBlocks ) =>
100
100
  replaceBlocks( clientIds, transformedBlocks );
101
+
102
+ /**
103
+ * The `isTemplate` check is a stopgap solution here.
104
+ * Ideally, the Transforms API should handle this
105
+ * by allowing to exclude blocks from wildcard transformations.
106
+ */
101
107
  const hasPossibleBlockTransformations =
102
- !! possibleBlockTransformations.length && canRemove;
108
+ !! possibleBlockTransformations.length && canRemove && ! isTemplate;
103
109
  const hasPatternTransformation = !! patterns?.length && canRemove;
104
110
  if ( ! hasBlockStyles && ! hasPossibleBlockTransformations ) {
105
111
  return (
@@ -17,9 +17,10 @@ import useBlockDisplayTitle from './use-block-display-title';
17
17
  * @param {Object} props
18
18
  * @param {string} props.clientId Client ID of block.
19
19
  * @param {number|undefined} props.maximumLength The maximum length that the block title string may be before truncated.
20
+ * @param {string|undefined} props.context The context to pass to `getBlockLabel`.
20
21
  *
21
22
  * @return {JSX.Element} Block title.
22
23
  */
23
- export default function BlockTitle( { clientId, maximumLength } ) {
24
- return useBlockDisplayTitle( clientId, maximumLength );
24
+ export default function BlockTitle( { clientId, maximumLength, context } ) {
25
+ return useBlockDisplayTitle( { clientId, maximumLength, context } );
25
26
  }
@@ -21,14 +21,20 @@ import { store as blockEditorStore } from '../../store';
21
21
  * @example
22
22
  *
23
23
  * ```js
24
- * useBlockDisplayTitle( 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1', 17 );
24
+ * useBlockDisplayTitle( { clientId: 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1', maximumLength: 17 } );
25
25
  * ```
26
26
  *
27
- * @param {string} clientId Client ID of block.
28
- * @param {number|undefined} maximumLength The maximum length that the block title string may be before truncated.
27
+ * @param {Object} props
28
+ * @param {string} props.clientId Client ID of block.
29
+ * @param {number|undefined} props.maximumLength The maximum length that the block title string may be before truncated.
30
+ * @param {string|undefined} props.context The context to pass to `getBlockLabel`.
29
31
  * @return {?string} Block title.
30
32
  */
31
- export default function useBlockDisplayTitle( clientId, maximumLength ) {
33
+ export default function useBlockDisplayTitle( {
34
+ clientId,
35
+ maximumLength,
36
+ context,
37
+ } ) {
32
38
  const { attributes, name, reusableBlockTitle } = useSelect(
33
39
  ( select ) => {
34
40
  if ( ! clientId ) {
@@ -63,7 +69,7 @@ export default function useBlockDisplayTitle( clientId, maximumLength ) {
63
69
  }
64
70
  const blockType = getBlockType( name );
65
71
  const blockLabel = blockType
66
- ? getBlockLabel( blockType, attributes )
72
+ ? getBlockLabel( blockType, attributes, context )
67
73
  : null;
68
74
 
69
75
  const label = reusableBlockTitle || blockLabel;
@@ -36,11 +36,13 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
36
36
  getBlockType( getBlockName( selectedBlockClientId ) ),
37
37
  hasParents: parents.length,
38
38
  showParentSelector:
39
+ parentBlockType &&
39
40
  hasBlockSupport(
40
41
  parentBlockType,
41
42
  '__experimentalParentSelector',
42
43
  true
43
- ) && selectedBlockClientIds.length <= 1,
44
+ ) &&
45
+ selectedBlockClientIds.length <= 1,
44
46
  };
45
47
  },
46
48
  []
@@ -82,6 +82,8 @@ export default function BorderRadiusControl( { onChange, values } ) {
82
82
  units={ units }
83
83
  />
84
84
  <RangeControl
85
+ label={ __( 'Border radius' ) }
86
+ hideLabelFromVision
85
87
  className="components-border-radius-control__range-control"
86
88
  value={ allValue ?? '' }
87
89
  min={ MIN_BORDER_RADIUS_VALUE }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { isString, kebabCase, reduce, upperFirst } from 'lodash';
4
+ import { kebabCase, reduce, upperFirst } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -78,7 +78,7 @@ function createColorHOC( colorTypes, withColorPalette ) {
78
78
  ( colorObject, colorType ) => {
79
79
  return {
80
80
  ...colorObject,
81
- ...( isString( colorType )
81
+ ...( typeof colorType === 'string'
82
82
  ? { [ colorType ]: kebabCase( colorType ) }
83
83
  : colorType ),
84
84
  };
@@ -7,16 +7,13 @@ import { every, isEmpty } from 'lodash';
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
- import { useState } from '@wordpress/element';
11
10
  import {
12
11
  BaseControl,
13
12
  __experimentalVStack as VStack,
14
- __experimentalToggleGroupControl as ToggleGroupControl,
15
- __experimentalToggleGroupControlOption as ToggleGroupControlOption,
13
+ TabPanel,
16
14
  ColorPalette,
17
15
  GradientPicker,
18
16
  } from '@wordpress/components';
19
- import { __ } from '@wordpress/i18n';
20
17
 
21
18
  /**
22
19
  * Internal dependencies
@@ -30,6 +27,19 @@ const colorsAndGradientKeys = [
30
27
  'disableCustomGradients',
31
28
  ];
32
29
 
30
+ const TAB_COLOR = {
31
+ name: 'color',
32
+ title: 'Solid color',
33
+ value: 'color',
34
+ };
35
+ const TAB_GRADIENT = {
36
+ name: 'gradient',
37
+ title: 'Gradient',
38
+ value: 'gradient',
39
+ };
40
+
41
+ const TABS_SETTINGS = [ TAB_COLOR, TAB_GRADIENT ];
42
+
33
43
  function ColorGradientControlInner( {
34
44
  colors,
35
45
  gradients,
@@ -52,13 +62,57 @@ function ColorGradientControlInner( {
52
62
  const canChooseAGradient =
53
63
  onGradientChange &&
54
64
  ( ! isEmpty( gradients ) || ! disableCustomGradients );
55
- const [ currentTab, setCurrentTab ] = useState(
56
- gradientValue ? 'gradient' : !! canChooseAColor && 'color'
57
- );
58
65
 
59
66
  if ( ! canChooseAColor && ! canChooseAGradient ) {
60
67
  return null;
61
68
  }
69
+
70
+ const tabPanels = {
71
+ [ TAB_COLOR.value ]: (
72
+ <ColorPalette
73
+ value={ colorValue }
74
+ onChange={
75
+ canChooseAGradient
76
+ ? ( newColor ) => {
77
+ onColorChange( newColor );
78
+ onGradientChange();
79
+ }
80
+ : onColorChange
81
+ }
82
+ { ...{ colors, disableCustomColors } }
83
+ __experimentalHasMultipleOrigins={
84
+ __experimentalHasMultipleOrigins
85
+ }
86
+ __experimentalIsRenderedInSidebar={
87
+ __experimentalIsRenderedInSidebar
88
+ }
89
+ clearable={ clearable }
90
+ enableAlpha={ enableAlpha }
91
+ />
92
+ ),
93
+ [ TAB_GRADIENT.value ]: (
94
+ <GradientPicker
95
+ value={ gradientValue }
96
+ onChange={
97
+ canChooseAColor
98
+ ? ( newGradient ) => {
99
+ onGradientChange( newGradient );
100
+ onColorChange();
101
+ }
102
+ : onGradientChange
103
+ }
104
+ { ...{ gradients, disableCustomGradients } }
105
+ __experimentalHasMultipleOrigins={
106
+ __experimentalHasMultipleOrigins
107
+ }
108
+ __experimentalIsRenderedInSidebar={
109
+ __experimentalIsRenderedInSidebar
110
+ }
111
+ clearable={ clearable }
112
+ />
113
+ ),
114
+ };
115
+
62
116
  return (
63
117
  <BaseControl
64
118
  className={ classnames(
@@ -78,66 +132,24 @@ function ColorGradientControlInner( {
78
132
  </legend>
79
133
  ) }
80
134
  { canChooseAColor && canChooseAGradient && (
81
- <ToggleGroupControl
82
- value={ currentTab }
83
- onChange={ setCurrentTab }
84
- label={ __( 'Select color type' ) }
85
- hideLabelFromVision
86
- isBlock
87
- >
88
- <ToggleGroupControlOption
89
- value="color"
90
- label={ __( 'Solid' ) }
91
- />
92
- <ToggleGroupControlOption
93
- value="gradient"
94
- label={ __( 'Gradient' ) }
95
- />
96
- </ToggleGroupControl>
97
- ) }
98
- { ( currentTab === 'color' || ! canChooseAGradient ) && (
99
- <ColorPalette
100
- value={ colorValue }
101
- onChange={
102
- canChooseAGradient
103
- ? ( newColor ) => {
104
- onColorChange( newColor );
105
- onGradientChange();
106
- }
107
- : onColorChange
135
+ <TabPanel
136
+ className="block-editor-color-gradient-control__tabs"
137
+ tabs={ TABS_SETTINGS }
138
+ initialTabName={
139
+ gradientValue
140
+ ? TAB_GRADIENT.value
141
+ : !! canChooseAColor && TAB_COLOR.value
108
142
  }
109
- { ...{ colors, disableCustomColors } }
110
- __experimentalHasMultipleOrigins={
111
- __experimentalHasMultipleOrigins
112
- }
113
- __experimentalIsRenderedInSidebar={
114
- __experimentalIsRenderedInSidebar
115
- }
116
- clearable={ clearable }
117
- enableAlpha={ enableAlpha }
118
- />
119
- ) }
120
- { ( currentTab === 'gradient' || ! canChooseAColor ) && (
121
- <GradientPicker
122
- value={ gradientValue }
123
- onChange={
124
- canChooseAColor
125
- ? ( newGradient ) => {
126
- onGradientChange( newGradient );
127
- onColorChange();
128
- }
129
- : onGradientChange
130
- }
131
- { ...{ gradients, disableCustomGradients } }
132
- __experimentalHasMultipleOrigins={
133
- __experimentalHasMultipleOrigins
134
- }
135
- __experimentalIsRenderedInSidebar={
136
- __experimentalIsRenderedInSidebar
137
- }
138
- clearable={ clearable }
139
- />
143
+ >
144
+ { ( tab ) => (
145
+ <div className="block-editor-color-gradient-control__tab-panel">
146
+ { tabPanels[ tab.value ] }
147
+ </div>
148
+ ) }
149
+ </TabPanel>
140
150
  ) }
151
+ { ! canChooseAGradient && tabPanels[ TAB_COLOR.value ] }
152
+ { ! canChooseAColor && tabPanels[ TAB_GRADIENT.value ] }
141
153
  </VStack>
142
154
  </fieldset>
143
155
  </BaseControl>
@@ -100,3 +100,7 @@
100
100
  .block-editor-panel-color-gradient-settings__dropdown {
101
101
  width: 100%;
102
102
  }
103
+
104
+ .block-editor-color-gradient-control__tab-panel {
105
+ padding-top: $grid-unit-10;
106
+ }
@@ -20,17 +20,6 @@ const getButtonWithAriaLabelStartPredicate =
20
20
  );
21
21
  };
22
22
 
23
- const getTabWithTestPredicate = ( text ) => ( element ) => {
24
- return (
25
- element.type === 'button' &&
26
- element.props[ 'aria-label' ] &&
27
- element.props[ 'aria-label' ] === text
28
- );
29
- };
30
-
31
- const colorTabButtonPredicate = getTabWithTestPredicate( 'Solid' );
32
- const gradientTabButtonPredicate = getTabWithTestPredicate( 'Gradient' );
33
-
34
23
  describe( 'ColorPaletteControl', () => {
35
24
  it( 'renders tabs if it is possible to select a color and a gradient rendering a color picker at the start', async () => {
36
25
  render(
@@ -63,8 +52,12 @@ describe( 'ColorPaletteControl', () => {
63
52
  );
64
53
 
65
54
  // Is showing the two tab buttons.
66
- expect( screen.queryByLabelText( 'Solid' ) ).toBeInTheDocument();
67
- expect( screen.queryByLabelText( 'Gradient' ) ).toBeInTheDocument();
55
+ expect(
56
+ screen.getByRole( 'tab', { name: 'Solid color' } )
57
+ ).toBeInTheDocument();
58
+ expect(
59
+ screen.getByRole( 'tab', { name: 'Gradient' } )
60
+ ).toBeInTheDocument();
68
61
 
69
62
  // Is showing the two predefined Colors.
70
63
  expect( screen.getAllByLabelText( /^Color:/ ) ).toHaveLength( 2 );
@@ -92,12 +85,12 @@ describe( 'ColorPaletteControl', () => {
92
85
  } );
93
86
 
94
87
  // Is not showing the two tab buttons.
95
- expect( wrapper.root.findAll( colorTabButtonPredicate ) ).toHaveLength(
96
- 0
97
- );
98
88
  expect(
99
- wrapper.root.findAll( gradientTabButtonPredicate )
100
- ).toHaveLength( 0 );
89
+ screen.queryByRole( 'tab', { name: 'Solid color' } )
90
+ ).not.toBeInTheDocument();
91
+ expect(
92
+ screen.queryByRole( 'tab', { name: 'Gradient' } )
93
+ ).not.toBeInTheDocument();
101
94
 
102
95
  // Is showing the two predefined Colors.
103
96
  expect(
@@ -139,12 +132,12 @@ describe( 'ColorPaletteControl', () => {
139
132
  } );
140
133
 
141
134
  // Is not showing the two tab buttons.
142
- expect( wrapper.root.findAll( colorTabButtonPredicate ) ).toHaveLength(
143
- 0
144
- );
145
135
  expect(
146
- wrapper.root.findAll( gradientTabButtonPredicate )
147
- ).toHaveLength( 0 );
136
+ screen.queryByRole( 'tab', { name: 'Solid color' } )
137
+ ).not.toBeInTheDocument();
138
+ expect(
139
+ screen.queryByRole( 'tab', { name: 'Gradient' } )
140
+ ).not.toBeInTheDocument();
148
141
 
149
142
  // Is showing the two predefined Gradients.
150
143
  expect(
@@ -90,6 +90,7 @@ function NonDefaultControls( { format, onChange } ) {
90
90
  _x( 'M j, Y', 'medium date format' ),
91
91
  _x( 'M j, Y g:i A', 'medium date format with time' ),
92
92
  _x( 'F j, Y', 'long date format' ),
93
+ _x( 'M j', 'short date format without the year' ),
93
94
  ] );
94
95
 
95
96
  const suggestedOptions = suggestedFormats.map(
@@ -65,12 +65,31 @@ function useStylesCompatibility() {
65
65
  return;
66
66
  }
67
67
 
68
- const isMatch = Array.from( cssRules ).find(
69
- ( { selectorText } ) =>
70
- selectorText &&
71
- ( selectorText.includes( `.${ BODY_CLASS_NAME }` ) ||
72
- selectorText.includes( `.${ BLOCK_PREFIX }` ) )
73
- );
68
+ function matchFromRules( _cssRules ) {
69
+ return Array.from( _cssRules ).find(
70
+ ( {
71
+ selectorText,
72
+ conditionText,
73
+ cssRules: __cssRules,
74
+ } ) => {
75
+ // If the rule is conditional then it will not have selector text.
76
+ // Recurse into child CSS ruleset to determine selector eligibility.
77
+ if ( conditionText ) {
78
+ return matchFromRules( __cssRules );
79
+ }
80
+
81
+ return (
82
+ selectorText &&
83
+ ( selectorText.includes(
84
+ `.${ BODY_CLASS_NAME }`
85
+ ) ||
86
+ selectorText.includes( `.${ BLOCK_PREFIX }` ) )
87
+ );
88
+ }
89
+ );
90
+ }
91
+
92
+ const isMatch = matchFromRules( cssRules );
74
93
 
75
94
  if (
76
95
  isMatch &&
@@ -342,7 +342,7 @@ $block-inserter-tabs-height: 44px;
342
342
  .block-editor-block-patterns-explorer {
343
343
  &__sidebar {
344
344
  position: absolute;
345
- top: $header-height;
345
+ top: $header-height + $grid-unit-20;
346
346
  left: 0;
347
347
  bottom: 0;
348
348
  width: $sidebar-width;
@@ -235,6 +235,7 @@ function LinkControl( {
235
235
  internalTextValue !== value?.title
236
236
  ) {
237
237
  onChange( {
238
+ ...value,
238
239
  url: currentInputValue,
239
240
  title: internalTextValue,
240
241
  } );
@@ -2417,10 +2417,12 @@ describe( 'Controlling link title text', () => {
2417
2417
  Simulate.keyDown( textInput, { keyCode: ENTER } );
2418
2418
  } );
2419
2419
 
2420
- expect( mockOnChange ).toHaveBeenCalledWith( {
2421
- title: textValue,
2422
- url: selectedLink.url,
2423
- } );
2420
+ expect( mockOnChange ).toHaveBeenCalledWith(
2421
+ expect.objectContaining( {
2422
+ title: textValue,
2423
+ url: selectedLink.url,
2424
+ } )
2425
+ );
2424
2426
 
2425
2427
  // The text input should not be showing as the form is submitted.
2426
2428
  expect(