@wordpress/block-editor 10.3.0 → 10.4.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 (264) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/alignment-control/ui.js +1 -1
  3. package/build/components/alignment-control/ui.js.map +1 -1
  4. package/build/components/block-alignment-control/constants.js +1 -1
  5. package/build/components/block-alignment-control/constants.js.map +1 -1
  6. package/build/components/block-alignment-matrix-control/index.js +1 -1
  7. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  8. package/build/components/block-compare/index.js +1 -3
  9. package/build/components/block-compare/index.js.map +1 -1
  10. package/build/components/block-edit/index.js +4 -2
  11. package/build/components/block-edit/index.js.map +1 -1
  12. package/build/components/block-list/block.js +3 -1
  13. package/build/components/block-list/block.js.map +1 -1
  14. package/build/components/block-popover/inbetween.js +2 -1
  15. package/build/components/block-popover/inbetween.js.map +1 -1
  16. package/build/components/block-popover/index.js +2 -1
  17. package/build/components/block-popover/index.js.map +1 -1
  18. package/build/components/block-preview/index.js +2 -4
  19. package/build/components/block-preview/index.js.map +1 -1
  20. package/build/components/block-settings-menu/block-settings-dropdown.js +2 -8
  21. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  22. package/build/components/block-switcher/index.js +2 -8
  23. package/build/components/block-switcher/index.js.map +1 -1
  24. package/build/components/block-switcher/preview-block-popover.js +1 -1
  25. package/build/components/block-switcher/preview-block-popover.js.map +1 -1
  26. package/build/components/block-tools/insertion-point.js +12 -2
  27. package/build/components/block-tools/insertion-point.js.map +1 -1
  28. package/build/components/block-vertical-alignment-control/ui.js +1 -1
  29. package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
  30. package/build/components/border-radius-control/all-input-control.js +2 -1
  31. package/build/components/border-radius-control/all-input-control.js.map +1 -1
  32. package/build/components/border-radius-control/index.js +2 -1
  33. package/build/components/border-radius-control/index.js.map +1 -1
  34. package/build/components/border-radius-control/input-controls.js +2 -1
  35. package/build/components/border-radius-control/input-controls.js.map +1 -1
  36. package/build/components/duotone-control/index.js +1 -1
  37. package/build/components/duotone-control/index.js.map +1 -1
  38. package/build/components/font-sizes/with-font-sizes.js +1 -1
  39. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  40. package/build/components/iframe/index.js +1 -1
  41. package/build/components/iframe/index.js.map +1 -1
  42. package/build/components/image-editor/constants.js +1 -1
  43. package/build/components/image-editor/constants.js.map +1 -1
  44. package/build/components/inner-blocks/index.js +6 -2
  45. package/build/components/inner-blocks/index.js.map +1 -1
  46. package/build/components/inserter/hooks/use-insertion-point.js +2 -7
  47. package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
  48. package/build/components/inserter/search-items.js +23 -2
  49. package/build/components/inserter/search-items.js.map +1 -1
  50. package/build/components/line-height-control/index.js +2 -1
  51. package/build/components/line-height-control/index.js.map +1 -1
  52. package/build/components/list-view/drop-indicator.js +2 -1
  53. package/build/components/list-view/drop-indicator.js.map +1 -1
  54. package/build/components/media-replace-flow/index.js +1 -1
  55. package/build/components/media-replace-flow/index.js.map +1 -1
  56. package/build/components/rich-text/format-toolbar/index.js +1 -1
  57. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  58. package/build/components/rich-text/format-toolbar-container.js +1 -1
  59. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  60. package/build/components/rich-text/use-paste-handler.js +1 -1
  61. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  62. package/build/components/spacing-sizes-control/all-input-control.js +6 -2
  63. package/build/components/spacing-sizes-control/all-input-control.js.map +1 -1
  64. package/build/components/spacing-sizes-control/axial-input-controls.js +6 -2
  65. package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
  66. package/build/components/spacing-sizes-control/index.js +6 -2
  67. package/build/components/spacing-sizes-control/index.js.map +1 -1
  68. package/build/components/spacing-sizes-control/input-controls.js +6 -2
  69. package/build/components/spacing-sizes-control/input-controls.js.map +1 -1
  70. package/build/components/spacing-sizes-control/spacing-input-control.js +12 -5
  71. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  72. package/build/components/url-input/index.js +1 -1
  73. package/build/components/url-input/index.js.map +1 -1
  74. package/build/hooks/border.js +1 -0
  75. package/build/hooks/border.js.map +1 -1
  76. package/build/hooks/dimensions.js +32 -4
  77. package/build/hooks/dimensions.js.map +1 -1
  78. package/build/hooks/font-size.js +1 -0
  79. package/build/hooks/font-size.js.map +1 -1
  80. package/build/hooks/layout.js +4 -3
  81. package/build/hooks/layout.js.map +1 -1
  82. package/build/hooks/margin.js +22 -16
  83. package/build/hooks/margin.js.map +1 -1
  84. package/build/hooks/padding.js +18 -11
  85. package/build/hooks/padding.js.map +1 -1
  86. package/build/hooks/utils.js +7 -6
  87. package/build/hooks/utils.js.map +1 -1
  88. package/build/layouts/constrained.js +0 -1
  89. package/build/layouts/constrained.js.map +1 -1
  90. package/build/layouts/flex.js +1 -1
  91. package/build/layouts/flex.js.map +1 -1
  92. package/build/store/actions.js +4 -0
  93. package/build/store/actions.js.map +1 -1
  94. package/build/store/array.js +1 -7
  95. package/build/store/array.js.map +1 -1
  96. package/build/store/selectors.js +46 -29
  97. package/build/store/selectors.js.map +1 -1
  98. package/build-module/components/alignment-control/ui.js +1 -1
  99. package/build-module/components/alignment-control/ui.js.map +1 -1
  100. package/build-module/components/block-alignment-control/constants.js +1 -1
  101. package/build-module/components/block-alignment-control/constants.js.map +1 -1
  102. package/build-module/components/block-alignment-matrix-control/index.js +1 -1
  103. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  104. package/build-module/components/block-compare/index.js +2 -3
  105. package/build-module/components/block-compare/index.js.map +1 -1
  106. package/build-module/components/block-edit/index.js +4 -2
  107. package/build-module/components/block-edit/index.js.map +1 -1
  108. package/build-module/components/block-list/block.js +3 -1
  109. package/build-module/components/block-list/block.js.map +1 -1
  110. package/build-module/components/block-popover/inbetween.js +2 -1
  111. package/build-module/components/block-popover/inbetween.js.map +1 -1
  112. package/build-module/components/block-popover/index.js +2 -1
  113. package/build-module/components/block-popover/index.js.map +1 -1
  114. package/build-module/components/block-preview/index.js +2 -3
  115. package/build-module/components/block-preview/index.js.map +1 -1
  116. package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -7
  117. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  118. package/build-module/components/block-switcher/index.js +2 -7
  119. package/build-module/components/block-switcher/index.js.map +1 -1
  120. package/build-module/components/block-switcher/preview-block-popover.js +1 -1
  121. package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
  122. package/build-module/components/block-tools/insertion-point.js +12 -2
  123. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  124. package/build-module/components/block-vertical-alignment-control/ui.js +1 -1
  125. package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
  126. package/build-module/components/border-radius-control/all-input-control.js +2 -1
  127. package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
  128. package/build-module/components/border-radius-control/index.js +2 -1
  129. package/build-module/components/border-radius-control/index.js.map +1 -1
  130. package/build-module/components/border-radius-control/input-controls.js +2 -1
  131. package/build-module/components/border-radius-control/input-controls.js.map +1 -1
  132. package/build-module/components/duotone-control/index.js +1 -1
  133. package/build-module/components/duotone-control/index.js.map +1 -1
  134. package/build-module/components/font-sizes/with-font-sizes.js +2 -2
  135. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  136. package/build-module/components/iframe/index.js +1 -1
  137. package/build-module/components/iframe/index.js.map +1 -1
  138. package/build-module/components/image-editor/constants.js +1 -1
  139. package/build-module/components/image-editor/constants.js.map +1 -1
  140. package/build-module/components/inner-blocks/index.js +6 -2
  141. package/build-module/components/inner-blocks/index.js.map +1 -1
  142. package/build-module/components/inserter/hooks/use-insertion-point.js +2 -6
  143. package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
  144. package/build-module/components/inserter/search-items.js +23 -3
  145. package/build-module/components/inserter/search-items.js.map +1 -1
  146. package/build-module/components/line-height-control/index.js +2 -1
  147. package/build-module/components/line-height-control/index.js.map +1 -1
  148. package/build-module/components/list-view/drop-indicator.js +2 -1
  149. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  150. package/build-module/components/media-replace-flow/index.js +1 -1
  151. package/build-module/components/media-replace-flow/index.js.map +1 -1
  152. package/build-module/components/rich-text/format-toolbar/index.js +1 -1
  153. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  154. package/build-module/components/rich-text/format-toolbar-container.js +1 -1
  155. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  156. package/build-module/components/rich-text/use-paste-handler.js +1 -1
  157. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  158. package/build-module/components/spacing-sizes-control/all-input-control.js +6 -2
  159. package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -1
  160. package/build-module/components/spacing-sizes-control/axial-input-controls.js +6 -2
  161. package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
  162. package/build-module/components/spacing-sizes-control/index.js +6 -2
  163. package/build-module/components/spacing-sizes-control/index.js.map +1 -1
  164. package/build-module/components/spacing-sizes-control/input-controls.js +6 -2
  165. package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -1
  166. package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -5
  167. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  168. package/build-module/components/url-input/index.js +1 -1
  169. package/build-module/components/url-input/index.js.map +1 -1
  170. package/build-module/hooks/border.js +1 -0
  171. package/build-module/hooks/border.js.map +1 -1
  172. package/build-module/hooks/dimensions.js +32 -4
  173. package/build-module/hooks/dimensions.js.map +1 -1
  174. package/build-module/hooks/font-size.js +1 -0
  175. package/build-module/hooks/font-size.js.map +1 -1
  176. package/build-module/hooks/layout.js +5 -4
  177. package/build-module/hooks/layout.js.map +1 -1
  178. package/build-module/hooks/margin.js +23 -17
  179. package/build-module/hooks/margin.js.map +1 -1
  180. package/build-module/hooks/padding.js +19 -12
  181. package/build-module/hooks/padding.js.map +1 -1
  182. package/build-module/hooks/utils.js +7 -7
  183. package/build-module/hooks/utils.js.map +1 -1
  184. package/build-module/layouts/constrained.js +0 -1
  185. package/build-module/layouts/constrained.js.map +1 -1
  186. package/build-module/layouts/flex.js +1 -1
  187. package/build-module/layouts/flex.js.map +1 -1
  188. package/build-module/store/actions.js +4 -0
  189. package/build-module/store/actions.js.map +1 -1
  190. package/build-module/store/array.js +1 -6
  191. package/build-module/store/array.js.map +1 -1
  192. package/build-module/store/selectors.js +47 -30
  193. package/build-module/store/selectors.js.map +1 -1
  194. package/build-style/style-rtl.css +49 -62
  195. package/build-style/style.css +45 -58
  196. package/package.json +29 -28
  197. package/src/components/alignment-control/ui.js +1 -1
  198. package/src/components/block-alignment-control/constants.js +1 -1
  199. package/src/components/block-alignment-matrix-control/index.js +1 -1
  200. package/src/components/block-breadcrumb/test/__snapshots__/index.js.snap +13 -11
  201. package/src/components/block-breadcrumb/test/index.js +1 -1
  202. package/src/components/block-compare/index.js +3 -2
  203. package/src/components/block-edit/index.js +2 -1
  204. package/src/components/block-list/block.js +2 -0
  205. package/src/components/block-list/style.scss +1 -1
  206. package/src/components/block-mover/stories/index.js +1 -1
  207. package/src/components/block-mover/style.scss +35 -0
  208. package/src/components/block-popover/inbetween.js +1 -0
  209. package/src/components/block-popover/index.js +1 -0
  210. package/src/components/block-popover/style.scss +0 -4
  211. package/src/components/block-preview/index.js +8 -3
  212. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -7
  213. package/src/components/block-switcher/index.js +2 -7
  214. package/src/components/block-switcher/preview-block-popover.js +1 -1
  215. package/src/components/block-tools/insertion-point.js +10 -1
  216. package/src/components/block-variation-picker/README.md +1 -1
  217. package/src/components/block-vertical-alignment-control/ui.js +1 -1
  218. package/src/components/border-radius-control/all-input-control.js +1 -0
  219. package/src/components/border-radius-control/index.js +1 -0
  220. package/src/components/border-radius-control/input-controls.js +1 -0
  221. package/src/components/border-radius-control/style.scss +15 -24
  222. package/src/components/color-palette/test/__snapshots__/control.js.snap +85 -83
  223. package/src/components/color-palette/test/control.js +1 -1
  224. package/src/components/duotone-control/index.js +1 -1
  225. package/src/components/font-sizes/with-font-sizes.js +2 -3
  226. package/src/components/iframe/index.js +1 -1
  227. package/src/components/image-editor/constants.js +1 -1
  228. package/src/components/inner-blocks/index.js +5 -1
  229. package/src/components/inner-blocks/test/index.js +4 -0
  230. package/src/components/inserter/hooks/use-insertion-point.js +3 -11
  231. package/src/components/inserter/search-items.js +23 -3
  232. package/src/components/inserter/test/search-items.js +6 -0
  233. package/src/components/inserter-list-item/style.scss +2 -0
  234. package/src/components/letter-spacing-control/README.md +55 -0
  235. package/src/components/line-height-control/index.js +1 -0
  236. package/src/components/link-control/README.md +3 -3
  237. package/src/components/list-view/drop-indicator.js +1 -0
  238. package/src/components/list-view/style.scss +1 -36
  239. package/src/components/media-replace-flow/index.js +1 -1
  240. package/src/components/media-replace-flow/test/index.js +69 -51
  241. package/src/components/rich-text/format-toolbar/index.js +1 -1
  242. package/src/components/rich-text/format-toolbar-container.js +1 -1
  243. package/src/components/rich-text/use-paste-handler.js +1 -1
  244. package/src/components/spacing-sizes-control/all-input-control.js +4 -0
  245. package/src/components/spacing-sizes-control/axial-input-controls.js +4 -0
  246. package/src/components/spacing-sizes-control/index.js +4 -0
  247. package/src/components/spacing-sizes-control/input-controls.js +4 -0
  248. package/src/components/spacing-sizes-control/spacing-input-control.js +10 -1
  249. package/src/components/spacing-sizes-control/style.scss +1 -0
  250. package/src/components/url-input/index.js +1 -1
  251. package/src/hooks/border.js +1 -0
  252. package/src/hooks/dimensions.js +32 -5
  253. package/src/hooks/font-size.js +1 -0
  254. package/src/hooks/layout.js +7 -9
  255. package/src/hooks/margin.js +19 -14
  256. package/src/hooks/padding.js +19 -16
  257. package/src/hooks/test/align.js +96 -72
  258. package/src/hooks/utils.js +5 -6
  259. package/src/layouts/constrained.js +0 -1
  260. package/src/layouts/flex.js +1 -1
  261. package/src/store/actions.js +4 -0
  262. package/src/store/array.js +1 -6
  263. package/src/store/selectors.js +28 -21
  264. package/src/store/test/selectors.js +1 -1
@@ -29,7 +29,7 @@ import {
29
29
  import { cleanEmptyObject } from './utils';
30
30
  import BlockPopover from '../components/block-popover';
31
31
  import SpacingSizesControl from '../components/spacing-sizes-control';
32
- import { getCustomValueFromPreset } from '../components/spacing-sizes-control/utils';
32
+ import { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';
33
33
 
34
34
  /**
35
35
  * Determines if there is margin support.
@@ -101,6 +101,8 @@ export function MarginEdit( props ) {
101
101
  name: blockName,
102
102
  attributes: { style },
103
103
  setAttributes,
104
+ onMouseOver,
105
+ onMouseOut,
104
106
  } = props;
105
107
 
106
108
  const spacingSizes = useSetting( 'spacing.spacingSizes' );
@@ -148,6 +150,8 @@ export function MarginEdit( props ) {
148
150
  units={ units }
149
151
  allowReset={ false }
150
152
  splitOnAxis={ splitOnAxis }
153
+ onMouseOver={ onMouseOver }
154
+ onMouseOut={ onMouseOut }
151
155
  />
152
156
  ) }
153
157
  { spacingSizes?.length > 0 && (
@@ -159,6 +163,8 @@ export function MarginEdit( props ) {
159
163
  units={ units }
160
164
  allowReset={ false }
161
165
  splitOnAxis={ false }
166
+ onMouseOver={ onMouseOver }
167
+ onMouseOut={ onMouseOut }
162
168
  />
163
169
  ) }
164
170
  </>
@@ -167,22 +173,21 @@ export function MarginEdit( props ) {
167
173
  } );
168
174
  }
169
175
 
170
- export function MarginVisualizer( { clientId, attributes } ) {
176
+ export function MarginVisualizer( { clientId, attributes, forceShow } ) {
171
177
  const margin = attributes?.style?.spacing?.margin;
172
- const spacingSizes = useSetting( 'spacing.spacingSizes' );
173
178
 
174
179
  const style = useMemo( () => {
175
180
  const marginTop = margin?.top
176
- ? getCustomValueFromPreset( margin?.top, spacingSizes )
181
+ ? getSpacingPresetCssVar( margin?.top )
177
182
  : 0;
178
183
  const marginRight = margin?.right
179
- ? getCustomValueFromPreset( margin?.right, spacingSizes )
184
+ ? getSpacingPresetCssVar( margin?.right )
180
185
  : 0;
181
186
  const marginBottom = margin?.bottom
182
- ? getCustomValueFromPreset( margin?.bottom, spacingSizes )
187
+ ? getSpacingPresetCssVar( margin?.bottom )
183
188
  : 0;
184
189
  const marginLeft = margin?.left
185
- ? getCustomValueFromPreset( margin?.left, spacingSizes )
190
+ ? getSpacingPresetCssVar( margin?.left )
186
191
  : 0;
187
192
 
188
193
  return {
@@ -190,10 +195,10 @@ export function MarginVisualizer( { clientId, attributes } ) {
190
195
  borderRightWidth: marginRight,
191
196
  borderBottomWidth: marginBottom,
192
197
  borderLeftWidth: marginLeft,
193
- top: marginTop !== 0 ? `calc(${ marginTop } * -1)` : 0,
194
- right: marginRight !== 0 ? `calc(${ marginRight } * -1)` : 0,
195
- bottom: marginBottom !== 0 ? `calc(${ marginBottom } * -1)` : 0,
196
- left: marginLeft !== 0 ? `calc(${ marginLeft } * -1)` : 0,
198
+ top: marginTop ? `calc(${ marginTop } * -1)` : 0,
199
+ right: marginRight ? `calc(${ marginRight } * -1)` : 0,
200
+ bottom: marginBottom ? `calc(${ marginBottom } * -1)` : 0,
201
+ left: marginLeft ? `calc(${ marginLeft } * -1)` : 0,
197
202
  };
198
203
  }, [ margin ] );
199
204
 
@@ -208,7 +213,7 @@ export function MarginVisualizer( { clientId, attributes } ) {
208
213
  };
209
214
 
210
215
  useEffect( () => {
211
- if ( ! isShallowEqual( margin, valueRef.current ) ) {
216
+ if ( ! isShallowEqual( margin, valueRef.current ) && ! forceShow ) {
212
217
  setIsActive( true );
213
218
  valueRef.current = margin;
214
219
 
@@ -220,9 +225,9 @@ export function MarginVisualizer( { clientId, attributes } ) {
220
225
  }
221
226
 
222
227
  return () => clearTimer();
223
- }, [ margin ] );
228
+ }, [ margin, forceShow ] );
224
229
 
225
- if ( ! isActive ) {
230
+ if ( ! isActive && ! forceShow ) {
226
231
  return null;
227
232
  }
228
233
 
@@ -29,10 +29,7 @@ import {
29
29
  import { cleanEmptyObject } from './utils';
30
30
  import BlockPopover from '../components/block-popover';
31
31
  import SpacingSizesControl from '../components/spacing-sizes-control';
32
- import {
33
- getSpacingPresetCssVar,
34
- isValueSpacingPreset,
35
- } from '../components/spacing-sizes-control/utils';
32
+ import { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';
36
33
  /**
37
34
  * Determines if there is padding support.
38
35
  *
@@ -103,6 +100,8 @@ export function PaddingEdit( props ) {
103
100
  name: blockName,
104
101
  attributes: { style },
105
102
  setAttributes,
103
+ onMouseOver,
104
+ onMouseOut,
106
105
  } = props;
107
106
 
108
107
  const spacingSizes = useSetting( 'spacing.spacingSizes' );
@@ -150,6 +149,8 @@ export function PaddingEdit( props ) {
150
149
  units={ units }
151
150
  allowReset={ false }
152
151
  splitOnAxis={ splitOnAxis }
152
+ onMouseOver={ onMouseOver }
153
+ onMouseOut={ onMouseOut }
153
154
  />
154
155
  ) }
155
156
  { spacingSizes?.length > 0 && (
@@ -161,6 +162,8 @@ export function PaddingEdit( props ) {
161
162
  units={ units }
162
163
  allowReset={ false }
163
164
  splitOnAxis={ splitOnAxis }
165
+ onMouseOver={ onMouseOver }
166
+ onMouseOut={ onMouseOut }
164
167
  />
165
168
  ) }
166
169
  </>
@@ -169,22 +172,22 @@ export function PaddingEdit( props ) {
169
172
  } );
170
173
  }
171
174
 
172
- export function PaddingVisualizer( { clientId, attributes } ) {
175
+ export function PaddingVisualizer( { clientId, attributes, forceShow } ) {
173
176
  const padding = attributes?.style?.spacing?.padding;
174
177
  const style = useMemo( () => {
175
178
  return {
176
- borderTopWidth: isValueSpacingPreset( padding?.top )
179
+ borderTopWidth: padding?.top
177
180
  ? getSpacingPresetCssVar( padding?.top )
178
- : padding?.top,
179
- borderRightWidth: isValueSpacingPreset( padding?.right )
181
+ : 0,
182
+ borderRightWidth: padding?.right
180
183
  ? getSpacingPresetCssVar( padding?.right )
181
- : padding?.right,
182
- borderBottomWidth: isValueSpacingPreset( padding?.bottom )
184
+ : 0,
185
+ borderBottomWidth: padding?.bottom
183
186
  ? getSpacingPresetCssVar( padding?.bottom )
184
- : padding?.bottom,
185
- borderLeftWidth: isValueSpacingPreset( padding?.left )
187
+ : 0,
188
+ borderLeftWidth: padding?.left
186
189
  ? getSpacingPresetCssVar( padding?.left )
187
- : padding?.left,
190
+ : 0,
188
191
  };
189
192
  }, [ padding ] );
190
193
 
@@ -199,7 +202,7 @@ export function PaddingVisualizer( { clientId, attributes } ) {
199
202
  };
200
203
 
201
204
  useEffect( () => {
202
- if ( ! isShallowEqual( padding, valueRef.current ) ) {
205
+ if ( ! isShallowEqual( padding, valueRef.current ) && ! forceShow ) {
203
206
  setIsActive( true );
204
207
  valueRef.current = padding;
205
208
 
@@ -211,9 +214,9 @@ export function PaddingVisualizer( { clientId, attributes } ) {
211
214
  }
212
215
 
213
216
  return () => clearTimer();
214
- }, [ padding ] );
217
+ }, [ padding, forceShow ] );
215
218
 
216
- if ( ! isActive ) {
219
+ if ( ! isActive && ! forceShow ) {
217
220
  return null;
218
221
  }
219
222
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import renderer, { act } from 'react-test-renderer';
4
+ import { render, screen } from '@testing-library/react';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -12,10 +12,13 @@ import {
12
12
  registerBlockType,
13
13
  unregisterBlockType,
14
14
  } from '@wordpress/blocks';
15
+ import { SlotFillProvider } from '@wordpress/components';
15
16
 
16
17
  /**
17
18
  * Internal dependencies
18
19
  */
20
+ import BlockControls from '../../components/block-controls';
21
+ import BlockEdit from '../../components/block-edit';
19
22
  import BlockEditorProvider from '../../components/provider';
20
23
  import {
21
24
  getValidAlignments,
@@ -31,6 +34,7 @@ describe( 'align', () => {
31
34
  save: noop,
32
35
  category: 'text',
33
36
  title: 'block title',
37
+ edit: ( { children } ) => <>{ children }</>,
34
38
  };
35
39
 
36
40
  afterEach( () => {
@@ -154,6 +158,12 @@ describe( 'align', () => {
154
158
  } );
155
159
 
156
160
  describe( 'withToolbarControls', () => {
161
+ const componentProps = {
162
+ name: 'core/foo',
163
+ attributes: {},
164
+ isSelected: true,
165
+ };
166
+
157
167
  it( 'should do nothing if no valid alignments', () => {
158
168
  registerBlockType( 'core/foo', blockSettings );
159
169
 
@@ -161,15 +171,21 @@ describe( 'align', () => {
161
171
  ( { wrapperProps } ) => <div { ...wrapperProps } />
162
172
  );
163
173
 
164
- const wrapper = renderer.create(
165
- <EnhancedComponent
166
- name="core/foo"
167
- attributes={ {} }
168
- isSelected
169
- />
174
+ render(
175
+ <SlotFillProvider>
176
+ <BlockEdit { ...componentProps }>
177
+ <EnhancedComponent { ...componentProps } />
178
+ </BlockEdit>
179
+ <BlockControls.Slot group="block" />
180
+ </SlotFillProvider>
170
181
  );
171
- // When there's only one child, `rendered` in the tree is an object not an array.
172
- expect( wrapper.toTree().rendered ).toBeInstanceOf( Object );
182
+
183
+ expect(
184
+ screen.queryByRole( 'button', {
185
+ name: 'Align',
186
+ expanded: false,
187
+ } )
188
+ ).not.toBeInTheDocument();
173
189
  } );
174
190
 
175
191
  it( 'should render toolbar controls if valid alignments', () => {
@@ -185,14 +201,21 @@ describe( 'align', () => {
185
201
  ( { wrapperProps } ) => <div { ...wrapperProps } />
186
202
  );
187
203
 
188
- const wrapper = renderer.create(
189
- <EnhancedComponent
190
- name="core/foo"
191
- attributes={ {} }
192
- isSelected
193
- />
204
+ render(
205
+ <SlotFillProvider>
206
+ <BlockEdit { ...componentProps }>
207
+ <EnhancedComponent { ...componentProps } />
208
+ </BlockEdit>
209
+ <BlockControls.Slot group="block" />
210
+ </SlotFillProvider>
194
211
  );
195
- expect( wrapper.toTree().rendered ).toHaveLength( 2 );
212
+
213
+ expect(
214
+ screen.getAllByRole( 'button', {
215
+ name: 'Align',
216
+ expanded: false,
217
+ } )
218
+ ).toHaveLength( 2 );
196
219
  } );
197
220
  } );
198
221
 
@@ -207,28 +230,27 @@ describe( 'align', () => {
207
230
  } );
208
231
 
209
232
  const EnhancedComponent = withDataAlign( ( { wrapperProps } ) => (
210
- <div { ...wrapperProps } />
233
+ <button { ...wrapperProps } />
211
234
  ) );
212
235
 
213
- let wrapper;
214
- act( () => {
215
- wrapper = renderer.create(
216
- <BlockEditorProvider
217
- settings={ { alignWide: true, supportsLayout: false } }
218
- value={ [] }
219
- >
220
- <EnhancedComponent
221
- attributes={ {
222
- align: 'wide',
223
- } }
224
- name="core/foo"
225
- />
226
- </BlockEditorProvider>
227
- );
228
- } );
229
- expect( wrapper.root.findByType( 'div' ).props ).toEqual( {
230
- 'data-align': 'wide',
231
- } );
236
+ render(
237
+ <BlockEditorProvider
238
+ settings={ { alignWide: true, supportsLayout: false } }
239
+ value={ [] }
240
+ >
241
+ <EnhancedComponent
242
+ attributes={ {
243
+ align: 'wide',
244
+ } }
245
+ name="core/foo"
246
+ />
247
+ </BlockEditorProvider>
248
+ );
249
+
250
+ expect( screen.getByRole( 'button' ) ).toHaveAttribute(
251
+ 'data-align',
252
+ 'wide'
253
+ );
232
254
  } );
233
255
 
234
256
  it( 'should not render wide/full wrapper props if wide controls are not enabled', () => {
@@ -241,26 +263,27 @@ describe( 'align', () => {
241
263
  } );
242
264
 
243
265
  const EnhancedComponent = withDataAlign( ( { wrapperProps } ) => (
244
- <div { ...wrapperProps } />
266
+ <button { ...wrapperProps } />
245
267
  ) );
246
268
 
247
- let wrapper;
248
- act( () => {
249
- wrapper = renderer.create(
250
- <BlockEditorProvider
251
- settings={ { alignWide: false } }
252
- value={ [] }
253
- >
254
- <EnhancedComponent
255
- name="core/foo"
256
- attributes={ {
257
- align: 'wide',
258
- } }
259
- />
260
- </BlockEditorProvider>
261
- );
262
- } );
263
- expect( wrapper.root.findByType( 'div' ).props ).toEqual( {} );
269
+ render(
270
+ <BlockEditorProvider
271
+ settings={ { alignWide: false } }
272
+ value={ [] }
273
+ >
274
+ <EnhancedComponent
275
+ name="core/foo"
276
+ attributes={ {
277
+ align: 'wide',
278
+ } }
279
+ />
280
+ </BlockEditorProvider>
281
+ );
282
+
283
+ expect( screen.getByRole( 'button' ) ).not.toHaveAttribute(
284
+ 'data-align',
285
+ 'wide'
286
+ );
264
287
  } );
265
288
 
266
289
  it( 'should not render invalid align', () => {
@@ -273,26 +296,27 @@ describe( 'align', () => {
273
296
  } );
274
297
 
275
298
  const EnhancedComponent = withDataAlign( ( { wrapperProps } ) => (
276
- <div { ...wrapperProps } />
299
+ <button { ...wrapperProps } />
277
300
  ) );
278
301
 
279
- let wrapper;
280
- act( () => {
281
- wrapper = renderer.create(
282
- <BlockEditorProvider
283
- settings={ { alignWide: true } }
284
- value={ [] }
285
- >
286
- <EnhancedComponent
287
- name="core/foo"
288
- attributes={ {
289
- align: 'wide',
290
- } }
291
- />
292
- </BlockEditorProvider>
293
- );
294
- } );
295
- expect( wrapper.root.findByType( 'div' ).props ).toEqual( {} );
302
+ render(
303
+ <BlockEditorProvider
304
+ settings={ { alignWide: true } }
305
+ value={ [] }
306
+ >
307
+ <EnhancedComponent
308
+ name="core/foo"
309
+ attributes={ {
310
+ align: 'wide',
311
+ } }
312
+ />
313
+ </BlockEditorProvider>
314
+ );
315
+
316
+ expect( screen.getByRole( 'button' ) ).not.toHaveAttribute(
317
+ 'data-align',
318
+ 'wide'
319
+ );
296
320
  } );
297
321
  } );
298
322
 
@@ -1,15 +1,13 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { pickBy, isEmpty, mapValues, get, setWith, clone } from 'lodash';
4
+ import { isEmpty, mapValues, get, setWith, clone } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { getBlockSupport } from '@wordpress/blocks';
10
10
 
11
- const identity = ( x ) => x;
12
-
13
11
  /**
14
12
  * Removed falsy values from nested object.
15
13
  *
@@ -24,9 +22,10 @@ export const cleanEmptyObject = ( object ) => {
24
22
  ) {
25
23
  return object;
26
24
  }
27
- const cleanedNestedObjects = pickBy(
28
- mapValues( object, cleanEmptyObject ),
29
- identity
25
+ const cleanedNestedObjects = Object.fromEntries(
26
+ Object.entries( mapValues( object, cleanEmptyObject ) ).filter(
27
+ ( [ , value ] ) => Boolean( value )
28
+ )
30
29
  );
31
30
  return isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;
32
31
  };
@@ -116,7 +116,6 @@ export default {
116
116
  ) }
117
117
  </p>
118
118
  <ToggleGroupControl
119
- __experimentalIsBorderless
120
119
  label={ __( 'Justification' ) }
121
120
  value={ justifyContent }
122
121
  onChange={ onJustificationChange }
@@ -257,7 +257,7 @@ function FlexLayoutJustifyContentControl( {
257
257
  onChange={ onJustificationChange }
258
258
  popoverProps={ {
259
259
  position: 'bottom right',
260
- isAlternate: true,
260
+ variant: 'toolbar',
261
261
  } }
262
262
  />
263
263
  );
@@ -1712,6 +1712,10 @@ export function setBlockVisibility( updates ) {
1712
1712
  /**
1713
1713
  * Action that sets whether a block is being temporaritly edited as blocks.
1714
1714
  *
1715
+ * DO-NOT-USE in production.
1716
+ * This action is created for internal/experimental only usage and may be
1717
+ * removed anytime without any warning, causing breakage on any plugin or theme invoking it.
1718
+ *
1715
1719
  * @param {?string} temporarilyEditingAsBlocks The block's clientId being temporaritly edited as blocks.
1716
1720
  */
1717
1721
  export function __unstableSetTemporarilyEditingAsBlocks(
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { castArray } from 'lodash';
5
-
6
1
  /**
7
2
  * Insert one or multiple elements into a given position of an array.
8
3
  *
@@ -15,7 +10,7 @@ import { castArray } from 'lodash';
15
10
  export function insertAt( array, elements, index ) {
16
11
  return [
17
12
  ...array.slice( 0, index ),
18
- ...castArray( elements ),
13
+ ...( Array.isArray( elements ) ? elements : [ elements ] ),
19
14
  ...array.slice( index ),
20
15
  ];
21
16
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { castArray, map, reduce, some, find, filter, orderBy } from 'lodash';
4
+ import { map, reduce, find, filter, orderBy } from 'lodash';
5
5
  import createSelector from 'rememo';
6
6
 
7
7
  /**
@@ -319,12 +319,13 @@ export const __experimentalGetGlobalBlocksByName = createSelector(
319
319
  */
320
320
  export const getBlocksByClientId = createSelector(
321
321
  ( state, clientIds ) =>
322
- map( castArray( clientIds ), ( clientId ) =>
323
- getBlock( state, clientId )
322
+ map(
323
+ Array.isArray( clientIds ) ? clientIds : [ clientIds ],
324
+ ( clientId ) => getBlock( state, clientId )
324
325
  ),
325
326
  ( state, clientIds ) =>
326
327
  map(
327
- castArray( clientIds ),
328
+ Array.isArray( clientIds ) ? clientIds : [ clientIds ],
328
329
  ( clientId ) => state.blocks.tree[ clientId ]
329
330
  )
330
331
  );
@@ -694,10 +695,7 @@ export const getSelectedBlockClientIds = createSelector(
694
695
  ( state ) => {
695
696
  const { selectionStart, selectionEnd } = state.selection;
696
697
 
697
- if (
698
- selectionStart.clientId === undefined ||
699
- selectionEnd.clientId === undefined
700
- ) {
698
+ if ( ! selectionStart.clientId || ! selectionEnd.clientId ) {
701
699
  return EMPTY_ARRAY;
702
700
  }
703
701
 
@@ -712,6 +710,7 @@ export const getSelectedBlockClientIds = createSelector(
712
710
  state,
713
711
  selectionStart.clientId
714
712
  );
713
+
715
714
  if ( rootClientId === null ) {
716
715
  return EMPTY_ARRAY;
717
716
  }
@@ -1183,8 +1182,7 @@ export function isBlockSelected( state, clientId ) {
1183
1182
  * @return {boolean} Whether the block as an inner block selected
1184
1183
  */
1185
1184
  export function hasSelectedInnerBlock( state, clientId, deep = false ) {
1186
- return some(
1187
- getBlockOrder( state, clientId ),
1185
+ return getBlockOrder( state, clientId ).some(
1188
1186
  ( innerClientId ) =>
1189
1187
  isBlockSelected( state, innerClientId ) ||
1190
1188
  isBlockMultiSelected( state, innerClientId ) ||
@@ -1332,7 +1330,7 @@ export function isAncestorBeingDragged( state, clientId ) {
1332
1330
  }
1333
1331
 
1334
1332
  const parents = getBlockParents( state, clientId );
1335
- return some( parents, ( parentClientId ) =>
1333
+ return parents.some( ( parentClientId ) =>
1336
1334
  isBlockBeingDragged( state, parentClientId )
1337
1335
  );
1338
1336
  }
@@ -1531,7 +1529,7 @@ const canInsertBlockTypeUnmemoized = (
1531
1529
  ...getBlockParents( state, rootClientId ),
1532
1530
  ];
1533
1531
 
1534
- hasBlockAllowedAncestor = some( ancestors, ( ancestorClientId ) =>
1532
+ hasBlockAllowedAncestor = ancestors.some( ( ancestorClientId ) =>
1535
1533
  checkAllowList(
1536
1534
  blockAllowedAncestorBlocks,
1537
1535
  getBlockName( state, ancestorClientId )
@@ -1845,13 +1843,10 @@ const buildBlockTypeItem =
1845
1843
 
1846
1844
  let isDisabled = false;
1847
1845
  if ( ! hasBlockSupport( blockType.name, 'multiple', true ) ) {
1848
- isDisabled = some(
1849
- getBlocksByClientId(
1850
- state,
1851
- getClientIdsWithDescendants( state )
1852
- ),
1853
- { name: blockType.name }
1854
- );
1846
+ isDisabled = getBlocksByClientId(
1847
+ state,
1848
+ getClientIdsWithDescendants( state )
1849
+ ).some( ( { name } ) => name === blockType.name );
1855
1850
  }
1856
1851
 
1857
1852
  const { time, count = 0 } = getInsertUsage( state, id ) || {};
@@ -2065,7 +2060,7 @@ export const getInserterItems = createSelector(
2065
2060
  */
2066
2061
  export const getBlockTransformItems = createSelector(
2067
2062
  ( state, blocks, rootClientId = null ) => {
2068
- const normalizedBlocks = castArray( blocks );
2063
+ const normalizedBlocks = Array.isArray( blocks ) ? blocks : [ blocks ];
2069
2064
  const [ sourceBlock ] = normalizedBlocks;
2070
2065
  const buildBlockTypeTransformItem = buildBlockTypeItem( state, {
2071
2066
  buildScope: 'transform',
@@ -2129,7 +2124,7 @@ export const getBlockTransformItems = createSelector(
2129
2124
  */
2130
2125
  export const hasInserterItems = createSelector(
2131
2126
  ( state, rootClientId = null ) => {
2132
- const hasBlockType = some( getBlockTypes(), ( blockType ) =>
2127
+ const hasBlockType = getBlockTypes().some( ( blockType ) =>
2133
2128
  canIncludeBlockTypeInInserter( state, blockType, rootClientId )
2134
2129
  );
2135
2130
  if ( hasBlockType ) {
@@ -2690,6 +2685,11 @@ export const __unstableGetVisibleBlocks = createSelector(
2690
2685
  ( state ) => [ state.blockVisibility ]
2691
2686
  );
2692
2687
 
2688
+ /**
2689
+ * DO-NOT-USE in production.
2690
+ * This selector is created for internal/experimental only usage and may be
2691
+ * removed anytime without any warning, causing breakage on any plugin or theme invoking it.
2692
+ */
2693
2693
  export const __unstableGetContentLockingParent = createSelector(
2694
2694
  ( state, clientId ) => {
2695
2695
  let current = clientId;
@@ -2705,6 +2705,13 @@ export const __unstableGetContentLockingParent = createSelector(
2705
2705
  ( state ) => [ state.blocks.parents, state.blockListSettings ]
2706
2706
  );
2707
2707
 
2708
+ /**
2709
+ * DO-NOT-USE in production.
2710
+ * This selector is created for internal/experimental only usage and may be
2711
+ * removed anytime without any warning, causing breakage on any plugin or theme invoking it.
2712
+ *
2713
+ * @param {Object} state Global application state.
2714
+ */
2708
2715
  export function __unstableGetTemporarilyEditingAsBlocks( state ) {
2709
2716
  return state.temporarilyEditingAsBlocks;
2710
2717
  }
@@ -3995,7 +3995,7 @@ describe( 'selectors', () => {
3995
3995
  } );
3996
3996
 
3997
3997
  describe( 'getInserterItems with core blocks prioritization', () => {
3998
- // This test is in a seperate `describe` because all other tests register
3998
+ // This test is in a separate `describe` because all other tests register
3999
3999
  // some test `core` blocks and interfere with the purpose of the specific test.
4000
4000
  // This tests the functionality to ensure core blocks are prioritized in the
4001
4001
  // returned results, because third party blocks can be registered earlier than