@wordpress/block-editor 10.4.0 → 10.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 (254) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +0 -1
  3. package/build/components/block-lock/menu-item.js +1 -1
  4. package/build/components/block-lock/menu-item.js.map +1 -1
  5. package/build/components/block-lock/modal.js +16 -9
  6. package/build/components/block-lock/modal.js.map +1 -1
  7. package/build/components/block-styles/utils.js +3 -3
  8. package/build/components/block-styles/utils.js.map +1 -1
  9. package/build/components/block-switcher/index.js +19 -4
  10. package/build/components/block-switcher/index.js.map +1 -1
  11. package/build/components/block-tools/selected-block-popover.js +27 -4
  12. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  13. package/build/components/colors/with-colors.js +4 -3
  14. package/build/components/colors/with-colors.js.map +1 -1
  15. package/build/components/font-sizes/fluid-utils.js +24 -40
  16. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  17. package/build/components/font-sizes/with-font-sizes.js +7 -5
  18. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  19. package/build/components/index.js +9 -0
  20. package/build/components/index.js.map +1 -1
  21. package/build/components/inner-blocks/index.js +5 -3
  22. package/build/components/inner-blocks/index.js.map +1 -1
  23. package/build/components/inserter/reusable-blocks-tab.js +4 -1
  24. package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
  25. package/build/components/link-control/index.js +18 -34
  26. package/build/components/link-control/index.js.map +1 -1
  27. package/build/components/link-control/search-input.js +1 -1
  28. package/build/components/link-control/search-input.js.map +1 -1
  29. package/build/components/link-control/use-internal-input-value.js +26 -0
  30. package/build/components/link-control/use-internal-input-value.js.map +1 -0
  31. package/build/components/list-view/block.js +5 -3
  32. package/build/components/list-view/block.js.map +1 -1
  33. package/build/components/list-view/branch.js +9 -3
  34. package/build/components/list-view/branch.js.map +1 -1
  35. package/build/components/off-canvas-editor/block-contents.js +100 -0
  36. package/build/components/off-canvas-editor/block-contents.js.map +1 -0
  37. package/build/components/off-canvas-editor/block-select-button.js +119 -0
  38. package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
  39. package/build/components/off-canvas-editor/block.js +292 -0
  40. package/build/components/off-canvas-editor/block.js.map +1 -0
  41. package/build/components/off-canvas-editor/branch.js +181 -0
  42. package/build/components/off-canvas-editor/branch.js.map +1 -0
  43. package/build/components/off-canvas-editor/context.js +19 -0
  44. package/build/components/off-canvas-editor/context.js.map +1 -0
  45. package/build/components/off-canvas-editor/drop-indicator.js +118 -0
  46. package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
  47. package/build/components/off-canvas-editor/expander.js +41 -0
  48. package/build/components/off-canvas-editor/expander.js.map +1 -0
  49. package/build/components/off-canvas-editor/index.js +204 -0
  50. package/build/components/off-canvas-editor/index.js.map +1 -0
  51. package/build/components/off-canvas-editor/leaf.js +60 -0
  52. package/build/components/off-canvas-editor/leaf.js.map +1 -0
  53. package/build/components/off-canvas-editor/use-block-selection.js +139 -0
  54. package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
  55. package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
  56. package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
  57. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
  58. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
  59. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
  60. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
  61. package/build/components/off-canvas-editor/utils.js +60 -0
  62. package/build/components/off-canvas-editor/utils.js.map +1 -0
  63. package/build/components/url-popover/index.js +31 -2
  64. package/build/components/url-popover/index.js.map +1 -1
  65. package/build/components/use-setting/index.js +1 -1
  66. package/build/components/use-setting/index.js.map +1 -1
  67. package/build/hooks/color-panel.js +17 -1
  68. package/build/hooks/color-panel.js.map +1 -1
  69. package/build/hooks/color.js +1 -1
  70. package/build/hooks/color.js.map +1 -1
  71. package/build/hooks/content-lock-ui.js +13 -6
  72. package/build/hooks/content-lock-ui.js.map +1 -1
  73. package/build/hooks/dimensions.js +44 -13
  74. package/build/hooks/dimensions.js.map +1 -1
  75. package/build/hooks/layout.js +2 -2
  76. package/build/hooks/layout.js.map +1 -1
  77. package/build/hooks/margin.js +4 -2
  78. package/build/hooks/margin.js.map +1 -1
  79. package/build/hooks/min-height.js +145 -0
  80. package/build/hooks/min-height.js.map +1 -0
  81. package/build/hooks/padding.js +4 -2
  82. package/build/hooks/padding.js.map +1 -1
  83. package/build/hooks/style.js +3 -2
  84. package/build/hooks/style.js.map +1 -1
  85. package/build/layouts/flex.js +22 -21
  86. package/build/layouts/flex.js.map +1 -1
  87. package/build/store/actions.js +26 -0
  88. package/build/store/actions.js.map +1 -1
  89. package/build/store/reducer.js +46 -14
  90. package/build/store/reducer.js.map +1 -1
  91. package/build/store/selectors.js +16 -2
  92. package/build/store/selectors.js.map +1 -1
  93. package/build-module/components/block-lock/menu-item.js +2 -2
  94. package/build-module/components/block-lock/menu-item.js.map +1 -1
  95. package/build-module/components/block-lock/modal.js +17 -10
  96. package/build-module/components/block-lock/modal.js.map +1 -1
  97. package/build-module/components/block-styles/utils.js +3 -3
  98. package/build-module/components/block-styles/utils.js.map +1 -1
  99. package/build-module/components/block-switcher/index.js +19 -4
  100. package/build-module/components/block-switcher/index.js.map +1 -1
  101. package/build-module/components/block-tools/selected-block-popover.js +27 -5
  102. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  103. package/build-module/components/colors/with-colors.js +5 -4
  104. package/build-module/components/colors/with-colors.js.map +1 -1
  105. package/build-module/components/font-sizes/fluid-utils.js +24 -40
  106. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  107. package/build-module/components/font-sizes/with-font-sizes.js +8 -6
  108. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  109. package/build-module/components/index.js +1 -0
  110. package/build-module/components/index.js.map +1 -1
  111. package/build-module/components/inner-blocks/index.js +5 -3
  112. package/build-module/components/inner-blocks/index.js.map +1 -1
  113. package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
  114. package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
  115. package/build-module/components/link-control/index.js +17 -34
  116. package/build-module/components/link-control/index.js.map +1 -1
  117. package/build-module/components/link-control/search-input.js +1 -1
  118. package/build-module/components/link-control/search-input.js.map +1 -1
  119. package/build-module/components/link-control/use-internal-input-value.js +18 -0
  120. package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
  121. package/build-module/components/list-view/block.js +5 -3
  122. package/build-module/components/list-view/block.js.map +1 -1
  123. package/build-module/components/list-view/branch.js +9 -3
  124. package/build-module/components/list-view/branch.js.map +1 -1
  125. package/build-module/components/off-canvas-editor/block-contents.js +85 -0
  126. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
  127. package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
  128. package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
  129. package/build-module/components/off-canvas-editor/block.js +268 -0
  130. package/build-module/components/off-canvas-editor/block.js.map +1 -0
  131. package/build-module/components/off-canvas-editor/branch.js +165 -0
  132. package/build-module/components/off-canvas-editor/branch.js.map +1 -0
  133. package/build-module/components/off-canvas-editor/context.js +7 -0
  134. package/build-module/components/off-canvas-editor/context.js.map +1 -0
  135. package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
  136. package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
  137. package/build-module/components/off-canvas-editor/expander.js +32 -0
  138. package/build-module/components/off-canvas-editor/expander.js.map +1 -0
  139. package/build-module/components/off-canvas-editor/index.js +181 -0
  140. package/build-module/components/off-canvas-editor/index.js.map +1 -0
  141. package/build-module/components/off-canvas-editor/leaf.js +45 -0
  142. package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
  143. package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
  144. package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
  145. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
  146. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
  147. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
  148. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
  149. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
  150. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
  151. package/build-module/components/off-canvas-editor/utils.js +44 -0
  152. package/build-module/components/off-canvas-editor/utils.js.map +1 -0
  153. package/build-module/components/url-popover/index.js +30 -3
  154. package/build-module/components/url-popover/index.js.map +1 -1
  155. package/build-module/components/use-setting/index.js +1 -1
  156. package/build-module/components/use-setting/index.js.map +1 -1
  157. package/build-module/hooks/color-panel.js +17 -1
  158. package/build-module/hooks/color-panel.js.map +1 -1
  159. package/build-module/hooks/color.js +1 -1
  160. package/build-module/hooks/color.js.map +1 -1
  161. package/build-module/hooks/content-lock-ui.js +15 -8
  162. package/build-module/hooks/content-lock-ui.js.map +1 -1
  163. package/build-module/hooks/dimensions.js +39 -12
  164. package/build-module/hooks/dimensions.js.map +1 -1
  165. package/build-module/hooks/layout.js +2 -2
  166. package/build-module/hooks/layout.js.map +1 -1
  167. package/build-module/hooks/margin.js +4 -2
  168. package/build-module/hooks/margin.js.map +1 -1
  169. package/build-module/hooks/min-height.js +122 -0
  170. package/build-module/hooks/min-height.js.map +1 -0
  171. package/build-module/hooks/padding.js +4 -2
  172. package/build-module/hooks/padding.js.map +1 -1
  173. package/build-module/hooks/style.js +4 -3
  174. package/build-module/hooks/style.js.map +1 -1
  175. package/build-module/layouts/flex.js +23 -22
  176. package/build-module/layouts/flex.js.map +1 -1
  177. package/build-module/store/actions.js +22 -0
  178. package/build-module/store/actions.js.map +1 -1
  179. package/build-module/store/reducer.js +44 -14
  180. package/build-module/store/reducer.js.map +1 -1
  181. package/build-module/store/selectors.js +13 -2
  182. package/build-module/store/selectors.js.map +1 -1
  183. package/build-style/style-rtl.css +39 -26
  184. package/build-style/style.css +39 -26
  185. package/package.json +28 -28
  186. package/src/components/alignment-control/README.md +1 -1
  187. package/src/components/block-alignment-control/test/index.native.js +4 -4
  188. package/src/components/block-draggable/test/helpers.native.js +3 -3
  189. package/src/components/block-draggable/test/index.native.js +27 -27
  190. package/src/components/block-list/style.scss +10 -5
  191. package/src/components/block-lock/menu-item.js +5 -2
  192. package/src/components/block-lock/modal.js +19 -36
  193. package/src/components/block-lock/style.scss +8 -17
  194. package/src/components/block-mover/style.scss +0 -1
  195. package/src/components/block-popover/style.scss +1 -1
  196. package/src/components/block-styles/utils.js +3 -3
  197. package/src/components/block-switcher/index.js +19 -4
  198. package/src/components/block-tools/selected-block-popover.js +80 -34
  199. package/src/components/block-tools/style.scss +15 -0
  200. package/src/components/colors/with-colors.js +13 -23
  201. package/src/components/default-block-appender/style.scss +1 -0
  202. package/src/components/font-sizes/fluid-utils.js +37 -64
  203. package/src/components/font-sizes/test/fluid-utils.js +5 -5
  204. package/src/components/font-sizes/with-font-sizes.js +14 -11
  205. package/src/components/index.js +1 -0
  206. package/src/components/inner-blocks/index.js +7 -4
  207. package/src/components/inserter/reusable-blocks-tab.js +4 -2
  208. package/src/components/inserter/style.scss +8 -7
  209. package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
  210. package/src/components/link-control/index.js +23 -39
  211. package/src/components/link-control/search-input.js +1 -1
  212. package/src/components/link-control/test/index.js +272 -241
  213. package/src/components/link-control/use-internal-input-value.js +22 -0
  214. package/src/components/list-view/block.js +4 -3
  215. package/src/components/list-view/branch.js +11 -6
  216. package/src/components/off-canvas-editor/README.md +5 -0
  217. package/src/components/off-canvas-editor/block-contents.js +89 -0
  218. package/src/components/off-canvas-editor/block-select-button.js +113 -0
  219. package/src/components/off-canvas-editor/block.js +335 -0
  220. package/src/components/off-canvas-editor/branch.js +210 -0
  221. package/src/components/off-canvas-editor/context.js +8 -0
  222. package/src/components/off-canvas-editor/drop-indicator.js +126 -0
  223. package/src/components/off-canvas-editor/expander.js +26 -0
  224. package/src/components/off-canvas-editor/index.js +216 -0
  225. package/src/components/off-canvas-editor/leaf.js +48 -0
  226. package/src/components/off-canvas-editor/style.scss +397 -0
  227. package/src/components/off-canvas-editor/test/utils.js +50 -0
  228. package/src/components/off-canvas-editor/use-block-selection.js +169 -0
  229. package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
  230. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
  231. package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
  232. package/src/components/off-canvas-editor/utils.js +58 -0
  233. package/src/components/responsive-block-control/test/index.js +69 -92
  234. package/src/components/url-popover/README.md +12 -3
  235. package/src/components/url-popover/index.js +33 -3
  236. package/src/components/use-setting/index.js +7 -1
  237. package/src/hooks/color-panel.js +13 -1
  238. package/src/hooks/color.js +2 -0
  239. package/src/hooks/content-lock-ui.js +46 -34
  240. package/src/hooks/dimensions.js +76 -16
  241. package/src/hooks/layout.js +2 -3
  242. package/src/hooks/margin.js +4 -3
  243. package/src/hooks/min-height.js +121 -0
  244. package/src/hooks/padding.js +4 -3
  245. package/src/hooks/style.js +10 -2
  246. package/src/hooks/test/style.js +4 -0
  247. package/src/hooks/test/use-typography-props.js +1 -1
  248. package/src/layouts/flex.js +43 -38
  249. package/src/store/actions.js +22 -0
  250. package/src/store/reducer.js +50 -40
  251. package/src/store/selectors.js +16 -9
  252. package/src/store/test/actions.js +18 -0
  253. package/src/store/test/reducer.js +40 -0
  254. package/src/store/test/selectors.js +19 -0
@@ -3,8 +3,13 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { useState } from '@wordpress/element';
6
- import { Button, Popover } from '@wordpress/components';
6
+ import {
7
+ Button,
8
+ Popover,
9
+ __experimentalPopoverPositionToPlacement as positionToPlacement,
10
+ } from '@wordpress/components';
7
11
  import { chevronDown } from '@wordpress/icons';
12
+ import deprecated from '@wordpress/deprecated';
8
13
 
9
14
  /**
10
15
  * Internal dependencies
@@ -12,14 +17,39 @@ import { chevronDown } from '@wordpress/icons';
12
17
  import LinkViewer from './link-viewer';
13
18
  import LinkEditor from './link-editor';
14
19
 
20
+ const DEFAULT_PLACEMENT = 'bottom';
21
+
15
22
  function URLPopover( {
16
23
  additionalControls,
17
24
  children,
18
25
  renderSettings,
19
- position = 'bottom center',
26
+ // The DEFAULT_PLACEMENT value is assigned inside the function's body
27
+ placement,
20
28
  focusOnMount = 'firstElement',
29
+ // Deprecated
30
+ position,
31
+ // Rest
21
32
  ...popoverProps
22
33
  } ) {
34
+ if ( position !== undefined ) {
35
+ deprecated( '`position` prop in wp.blockEditor.URLPopover', {
36
+ since: '6.2',
37
+ alternative: '`placement` prop',
38
+ } );
39
+ }
40
+
41
+ // Compute popover's placement:
42
+ // - give priority to `placement` prop, if defined
43
+ // - otherwise, compute it from the legacy `position` prop (if defined)
44
+ // - finally, fallback to the DEFAULT_PLACEMENT.
45
+ let computedPlacement;
46
+ if ( placement !== undefined ) {
47
+ computedPlacement = placement;
48
+ } else if ( position !== undefined ) {
49
+ computedPlacement = positionToPlacement( position );
50
+ }
51
+ computedPlacement = computedPlacement || DEFAULT_PLACEMENT;
52
+
23
53
  const [ isSettingsExpanded, setIsSettingsExpanded ] = useState( false );
24
54
 
25
55
  const showSettings = !! renderSettings && isSettingsExpanded;
@@ -32,7 +62,7 @@ function URLPopover( {
32
62
  <Popover
33
63
  className="block-editor-url-popover"
34
64
  focusOnMount={ focusOnMount }
35
- position={ position }
65
+ placement={ computedPlacement }
36
66
  shift
37
67
  { ...popoverProps }
38
68
  >
@@ -18,7 +18,13 @@ import {
18
18
  import { useBlockEditContext } from '../block-edit';
19
19
  import { store as blockEditorStore } from '../../store';
20
20
 
21
- const blockedPaths = [ 'color', 'border', 'typography', 'spacing' ];
21
+ const blockedPaths = [
22
+ 'color',
23
+ 'border',
24
+ 'dimensions',
25
+ 'typography',
26
+ 'spacing',
27
+ ];
22
28
 
23
29
  const deprecatedFlags = {
24
30
  'color.palette': ( settings ) => settings.colors,
@@ -29,7 +29,19 @@ export default function ColorPanel( {
29
29
  const definedColors = settings.filter( ( setting ) => setting?.colorValue );
30
30
 
31
31
  useEffect( () => {
32
- if ( ! enableContrastChecking || ! definedColors.length ) {
32
+ if ( ! enableContrastChecking ) {
33
+ return;
34
+ }
35
+ if ( ! definedColors.length ) {
36
+ if ( detectedBackgroundColor ) {
37
+ setDetectedBackgroundColor();
38
+ }
39
+ if ( detectedColor ) {
40
+ setDetectedColor();
41
+ }
42
+ if ( detectedLinkColor ) {
43
+ setDetectedColor();
44
+ }
33
45
  return;
34
46
  }
35
47
 
@@ -459,6 +459,8 @@ export function ColorEdit( props ) {
459
459
  Platform.OS === 'web' &&
460
460
  ! gradient &&
461
461
  ! style?.color?.gradient &&
462
+ hasBackgroundColor &&
463
+ ( hasLinkColor || hasTextColor ) &&
462
464
  // Contrast checking is enabled by default.
463
465
  // Deactivating it requires `enableContrastChecker` to have
464
466
  // an explicit value of `false`.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { ToolbarButton } from '@wordpress/components';
4
+ import { ToolbarButton, MenuItem } from '@wordpress/components';
5
5
  import { createHigherOrderComponent } from '@wordpress/compose';
6
6
  import { useDispatch, useSelect } from '@wordpress/data';
7
7
  import { addFilter } from '@wordpress/hooks';
@@ -12,7 +12,7 @@ import { useEffect, useRef, useCallback } from '@wordpress/element';
12
12
  * Internal dependencies
13
13
  */
14
14
  import { store as blockEditorStore } from '../store';
15
- import { BlockControls } from '../components';
15
+ import { BlockControls, BlockSettingsMenuControls } from '../components';
16
16
  /**
17
17
  * External dependencies
18
18
  */
@@ -107,39 +107,51 @@ export const withBlockControls = createHigherOrderComponent(
107
107
  return (
108
108
  <>
109
109
  { isEditingAsBlocks && ! isContentLocked && (
110
- <StopEditingAsBlocksOnOutsideSelect
111
- clientId={ props.clientId }
112
- stopEditingAsBlock={ stopEditingAsBlock }
113
- />
110
+ <>
111
+ <StopEditingAsBlocksOnOutsideSelect
112
+ clientId={ props.clientId }
113
+ stopEditingAsBlock={ stopEditingAsBlock }
114
+ />
115
+ <BlockControls group="other">
116
+ <ToolbarButton
117
+ onClick={ () => {
118
+ stopEditingAsBlock();
119
+ } }
120
+ >
121
+ { __( 'Done' ) }
122
+ </ToolbarButton>
123
+ </BlockControls>
124
+ </>
125
+ ) }
126
+ { ! isEditingAsBlocks && isContentLocked && props.isSelected && (
127
+ <BlockSettingsMenuControls>
128
+ { ( { onClose } ) => (
129
+ <MenuItem
130
+ onClick={ () => {
131
+ __unstableMarkNextChangeAsNotPersistent();
132
+ updateBlockAttributes( props.clientId, {
133
+ templateLock: undefined,
134
+ } );
135
+ updateBlockListSettings( props.clientId, {
136
+ ...getBlockListSettings(
137
+ props.clientId
138
+ ),
139
+ templateLock: false,
140
+ } );
141
+ focusModeToRevert.current =
142
+ getSettings().focusMode;
143
+ updateSettings( { focusMode: true } );
144
+ __unstableSetTemporarilyEditingAsBlocks(
145
+ props.clientId
146
+ );
147
+ onClose();
148
+ } }
149
+ >
150
+ { __( 'Modify' ) }
151
+ </MenuItem>
152
+ ) }
153
+ </BlockSettingsMenuControls>
114
154
  ) }
115
- <BlockControls group="other">
116
- <ToolbarButton
117
- onClick={ () => {
118
- if ( isEditingAsBlocks && ! isContentLocked ) {
119
- stopEditingAsBlock();
120
- } else {
121
- __unstableMarkNextChangeAsNotPersistent();
122
- updateBlockAttributes( props.clientId, {
123
- templateLock: undefined,
124
- } );
125
- updateBlockListSettings( props.clientId, {
126
- ...getBlockListSettings( props.clientId ),
127
- templateLock: false,
128
- } );
129
- focusModeToRevert.current =
130
- getSettings().focusMode;
131
- updateSettings( { focusMode: true } );
132
- __unstableSetTemporarilyEditingAsBlocks(
133
- props.clientId
134
- );
135
- }
136
- } }
137
- >
138
- { isEditingAsBlocks && ! isContentLocked
139
- ? __( 'Done' )
140
- : __( 'Modify' ) }
141
- </ToolbarButton>
142
- </BlockControls>
143
155
  <BlockEdit
144
156
  { ...props }
145
157
  className={ classnames(
@@ -10,6 +10,7 @@ import { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/compo
10
10
  import { Platform, useState } from '@wordpress/element';
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import { getBlockSupport } from '@wordpress/blocks';
13
+ import { useDispatch } from '@wordpress/data';
13
14
 
14
15
  /**
15
16
  * Internal dependencies
@@ -30,6 +31,13 @@ import {
30
31
  resetMargin,
31
32
  useIsMarginDisabled,
32
33
  } from './margin';
34
+ import {
35
+ MinHeightEdit,
36
+ hasMinHeightSupport,
37
+ hasMinHeightValue,
38
+ resetMinHeight,
39
+ useIsMinHeightDisabled,
40
+ } from './min-height';
33
41
  import {
34
42
  PaddingEdit,
35
43
  PaddingVisualizer,
@@ -39,15 +47,29 @@ import {
39
47
  useIsPaddingDisabled,
40
48
  } from './padding';
41
49
  import useSetting from '../components/use-setting';
50
+ import { store as blockEditorStore } from '../store';
42
51
 
52
+ export const DIMENSIONS_SUPPORT_KEY = 'dimensions';
43
53
  export const SPACING_SUPPORT_KEY = 'spacing';
44
54
  export const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];
45
55
  export const AXIAL_SIDES = [ 'vertical', 'horizontal' ];
46
56
 
47
57
  function useVisualizerMouseOver() {
48
58
  const [ isMouseOver, setIsMouseOver ] = useState( false );
49
- const onMouseOver = () => setIsMouseOver( true );
50
- const onMouseOut = () => setIsMouseOver( false );
59
+ const {
60
+ __experimentalHideBlockInterface: hideBlockInterface,
61
+ __experimentalShowBlockInterface: showBlockInterface,
62
+ } = useDispatch( blockEditorStore );
63
+ const onMouseOver = ( e ) => {
64
+ e.stopPropagation();
65
+ hideBlockInterface();
66
+ setIsMouseOver( true );
67
+ };
68
+ const onMouseOut = ( e ) => {
69
+ e.stopPropagation();
70
+ showBlockInterface();
71
+ setIsMouseOver( false );
72
+ };
51
73
  return { isMouseOver, onMouseOver, onMouseOut };
52
74
  }
53
75
 
@@ -56,12 +78,13 @@ function useVisualizerMouseOver() {
56
78
  *
57
79
  * @param {Object} props Block props.
58
80
  *
59
- * @return {WPElement} Inspector controls for spacing support features.
81
+ * @return {WPElement} Inspector controls for dimensions and spacing support features.
60
82
  */
61
83
  export function DimensionsPanel( props ) {
62
84
  const isGapDisabled = useIsGapDisabled( props );
63
85
  const isPaddingDisabled = useIsPaddingDisabled( props );
64
86
  const isMarginDisabled = useIsMarginDisabled( props );
87
+ const isMinHeightDisabled = useIsMinHeightDisabled( props );
65
88
  const isDisabled = useIsDimensionsDisabled( props );
66
89
  const isSupported = hasDimensionsSupport( props.name );
67
90
  const spacingSizes = useSetting( 'spacing.spacingSizes' );
@@ -72,21 +95,27 @@ export function DimensionsPanel( props ) {
72
95
  return null;
73
96
  }
74
97
 
98
+ const defaultDimensionsControls = getBlockSupport( props.name, [
99
+ DIMENSIONS_SUPPORT_KEY,
100
+ '__experimentalDefaultControls',
101
+ ] );
102
+
75
103
  const defaultSpacingControls = getBlockSupport( props.name, [
76
104
  SPACING_SUPPORT_KEY,
77
105
  '__experimentalDefaultControls',
78
106
  ] );
79
107
 
80
- const createResetAllFilter = ( attribute ) => ( newAttributes ) => ( {
81
- ...newAttributes,
82
- style: {
83
- ...newAttributes.style,
84
- spacing: {
85
- ...newAttributes.style?.spacing,
86
- [ attribute ]: undefined,
108
+ const createResetAllFilter =
109
+ ( attribute, featureSet ) => ( newAttributes ) => ( {
110
+ ...newAttributes,
111
+ style: {
112
+ ...newAttributes.style,
113
+ [ featureSet ]: {
114
+ ...newAttributes.style?.[ featureSet ],
115
+ [ attribute ]: undefined,
116
+ },
87
117
  },
88
- },
89
- } );
118
+ } );
90
119
 
91
120
  const spacingClassnames = classnames( {
92
121
  'tools-panel-item-spacing': spacingSizes && spacingSizes.length > 0,
@@ -101,7 +130,10 @@ export function DimensionsPanel( props ) {
101
130
  hasValue={ () => hasPaddingValue( props ) }
102
131
  label={ __( 'Padding' ) }
103
132
  onDeselect={ () => resetPadding( props ) }
104
- resetAllFilter={ createResetAllFilter( 'padding' ) }
133
+ resetAllFilter={ createResetAllFilter(
134
+ 'padding',
135
+ 'spacing'
136
+ ) }
105
137
  isShownByDefault={ defaultSpacingControls?.padding }
106
138
  panelId={ props.clientId }
107
139
  >
@@ -118,7 +150,10 @@ export function DimensionsPanel( props ) {
118
150
  hasValue={ () => hasMarginValue( props ) }
119
151
  label={ __( 'Margin' ) }
120
152
  onDeselect={ () => resetMargin( props ) }
121
- resetAllFilter={ createResetAllFilter( 'margin' ) }
153
+ resetAllFilter={ createResetAllFilter(
154
+ 'margin',
155
+ 'spacing'
156
+ ) }
122
157
  isShownByDefault={ defaultSpacingControls?.margin }
123
158
  panelId={ props.clientId }
124
159
  >
@@ -135,13 +170,34 @@ export function DimensionsPanel( props ) {
135
170
  hasValue={ () => hasGapValue( props ) }
136
171
  label={ __( 'Block spacing' ) }
137
172
  onDeselect={ () => resetGap( props ) }
138
- resetAllFilter={ createResetAllFilter( 'blockGap' ) }
173
+ resetAllFilter={ createResetAllFilter(
174
+ 'blockGap',
175
+ 'spacing'
176
+ ) }
139
177
  isShownByDefault={ defaultSpacingControls?.blockGap }
140
178
  panelId={ props.clientId }
141
179
  >
142
180
  <GapEdit { ...props } />
143
181
  </ToolsPanelItem>
144
182
  ) }
183
+ { ! isMinHeightDisabled && (
184
+ <ToolsPanelItem
185
+ className="single-column"
186
+ hasValue={ () => hasMinHeightValue( props ) }
187
+ label={ __( 'Min. height' ) }
188
+ onDeselect={ () => resetMinHeight( props ) }
189
+ resetAllFilter={ createResetAllFilter(
190
+ 'minHeight',
191
+ 'dimensions'
192
+ ) }
193
+ isShownByDefault={
194
+ defaultDimensionsControls?.minHeight
195
+ }
196
+ panelId={ props.clientId }
197
+ >
198
+ <MinHeightEdit { ...props } />
199
+ </ToolsPanelItem>
200
+ ) }
145
201
  </InspectorControls>
146
202
  { ! isPaddingDisabled && (
147
203
  <PaddingVisualizer
@@ -173,6 +229,7 @@ export function hasDimensionsSupport( blockName ) {
173
229
 
174
230
  return (
175
231
  hasGapSupport( blockName ) ||
232
+ hasMinHeightSupport( blockName ) ||
176
233
  hasPaddingSupport( blockName ) ||
177
234
  hasMarginSupport( blockName )
178
235
  );
@@ -187,10 +244,13 @@ export function hasDimensionsSupport( blockName ) {
187
244
  */
188
245
  const useIsDimensionsDisabled = ( props = {} ) => {
189
246
  const gapDisabled = useIsGapDisabled( props );
247
+ const minHeightDisabled = useIsMinHeightDisabled( props );
190
248
  const paddingDisabled = useIsPaddingDisabled( props );
191
249
  const marginDisabled = useIsMarginDisabled( props );
192
250
 
193
- return gapDisabled && paddingDisabled && marginDisabled;
251
+ return (
252
+ gapDisabled && minHeightDisabled && paddingDisabled && marginDisabled
253
+ );
194
254
  };
195
255
 
196
256
  /**
@@ -385,8 +385,7 @@ export const withLayoutStyles = createHigherOrderComponent(
385
385
  }
386
386
 
387
387
  // Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.
388
- const className = classnames(
389
- props?.className,
388
+ const layoutClassNames = classnames(
390
389
  {
391
390
  [ `wp-container-${ id }` ]: shouldRenderLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.
392
391
  },
@@ -410,7 +409,7 @@ export const withLayoutStyles = createHigherOrderComponent(
410
409
  ) }
411
410
  <BlockListBlock
412
411
  { ...props }
413
- __unstableLayoutClassNames={ className }
412
+ __unstableLayoutClassNames={ layoutClassNames }
414
413
  />
415
414
  </>
416
415
  );
@@ -217,14 +217,15 @@ export function MarginVisualizer( { clientId, attributes, forceShow } ) {
217
217
  setIsActive( true );
218
218
  valueRef.current = margin;
219
219
 
220
- clearTimer();
221
-
222
220
  timeoutRef.current = setTimeout( () => {
223
221
  setIsActive( false );
224
222
  }, 400 );
225
223
  }
226
224
 
227
- return () => clearTimer();
225
+ return () => {
226
+ setIsActive( false );
227
+ clearTimer();
228
+ };
228
229
  }, [ margin, forceShow ] );
229
230
 
230
231
  if ( ! isActive && ! forceShow ) {
@@ -0,0 +1,121 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { getBlockSupport } from '@wordpress/blocks';
5
+ import {
6
+ __experimentalUseCustomUnits as useCustomUnits,
7
+ __experimentalUnitControl as UnitControl,
8
+ } from '@wordpress/components';
9
+ import { __ } from '@wordpress/i18n';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import useSetting from '../components/use-setting';
15
+ import { DIMENSIONS_SUPPORT_KEY } from './dimensions';
16
+ import { cleanEmptyObject } from './utils';
17
+
18
+ /**
19
+ * Determines if there is minHeight support.
20
+ *
21
+ * @param {string|Object} blockType Block name or Block Type object.
22
+ * @return {boolean} Whether there is support.
23
+ */
24
+ export function hasMinHeightSupport( blockType ) {
25
+ const support = getBlockSupport( blockType, DIMENSIONS_SUPPORT_KEY );
26
+ return !! ( true === support || support?.minHeight );
27
+ }
28
+
29
+ /**
30
+ * Checks if there is a current value in the minHeight block support attributes.
31
+ *
32
+ * @param {Object} props Block props.
33
+ * @return {boolean} Whether or not the block has a minHeight value set.
34
+ */
35
+ export function hasMinHeightValue( props ) {
36
+ return props.attributes.style?.dimensions?.minHeight !== undefined;
37
+ }
38
+
39
+ /**
40
+ * Resets the minHeight block support attributes. This can be used when disabling
41
+ * the padding support controls for a block via a `ToolsPanel`.
42
+ *
43
+ * @param {Object} props Block props.
44
+ * @param {Object} props.attributes Block's attributes.
45
+ * @param {Object} props.setAttributes Function to set block's attributes.
46
+ */
47
+ export function resetMinHeight( { attributes = {}, setAttributes } ) {
48
+ const { style } = attributes;
49
+
50
+ setAttributes( {
51
+ style: cleanEmptyObject( {
52
+ ...style,
53
+ dimensions: {
54
+ ...style?.dimensions,
55
+ minHeight: undefined,
56
+ },
57
+ } ),
58
+ } );
59
+ }
60
+
61
+ /**
62
+ * Custom hook that checks if minHeight controls have been disabled.
63
+ *
64
+ * @param {string} name The name of the block.
65
+ * @return {boolean} Whether minHeight control is disabled.
66
+ */
67
+ export function useIsMinHeightDisabled( { name: blockName } = {} ) {
68
+ const isDisabled = ! useSetting( 'dimensions.minHeight' );
69
+ return ! hasMinHeightSupport( blockName ) || isDisabled;
70
+ }
71
+
72
+ /**
73
+ * Inspector control panel containing the minHeight related configuration.
74
+ *
75
+ * @param {Object} props Block props.
76
+ * @return {WPElement} Edit component for height.
77
+ */
78
+ export function MinHeightEdit( props ) {
79
+ const {
80
+ attributes: { style },
81
+ setAttributes,
82
+ } = props;
83
+
84
+ const units = useCustomUnits( {
85
+ availableUnits: useSetting( 'dimensions.units' ) || [
86
+ '%',
87
+ 'px',
88
+ 'em',
89
+ 'rem',
90
+ 'vh',
91
+ 'vw',
92
+ ],
93
+ } );
94
+
95
+ if ( useIsMinHeightDisabled( props ) ) {
96
+ return null;
97
+ }
98
+
99
+ const onChange = ( next ) => {
100
+ const newStyle = {
101
+ ...style,
102
+ dimensions: {
103
+ ...style?.dimensions,
104
+ minHeight: next,
105
+ },
106
+ };
107
+
108
+ setAttributes( { style: cleanEmptyObject( newStyle ) } );
109
+ };
110
+
111
+ return (
112
+ <UnitControl
113
+ label={ __( 'Min. height' ) }
114
+ value={ style?.dimensions?.minHeight }
115
+ units={ units }
116
+ onChange={ onChange }
117
+ min={ 0 }
118
+ size={ '__unstable-large' }
119
+ />
120
+ );
121
+ }
@@ -206,14 +206,15 @@ export function PaddingVisualizer( { clientId, attributes, forceShow } ) {
206
206
  setIsActive( true );
207
207
  valueRef.current = padding;
208
208
 
209
- clearTimer();
210
-
211
209
  timeoutRef.current = setTimeout( () => {
212
210
  setIsActive( false );
213
211
  }, 400 );
214
212
  }
215
213
 
216
- return () => clearTimer();
214
+ return () => {
215
+ setIsActive( false );
216
+ clearTimer();
217
+ };
217
218
  }, [ padding, forceShow ] );
218
219
 
219
220
  if ( ! isActive && ! forceShow ) {
@@ -27,7 +27,11 @@ import {
27
27
  TYPOGRAPHY_SUPPORT_KEY,
28
28
  TYPOGRAPHY_SUPPORT_KEYS,
29
29
  } from './typography';
30
- import { SPACING_SUPPORT_KEY, DimensionsPanel } from './dimensions';
30
+ import {
31
+ DIMENSIONS_SUPPORT_KEY,
32
+ SPACING_SUPPORT_KEY,
33
+ DimensionsPanel,
34
+ } from './dimensions';
31
35
  import useDisplayBlockControls from '../components/use-display-block-controls';
32
36
  import { shouldSkipSerialization } from './utils';
33
37
 
@@ -35,6 +39,7 @@ const styleSupportKeys = [
35
39
  ...TYPOGRAPHY_SUPPORT_KEYS,
36
40
  BORDER_SUPPORT_KEY,
37
41
  COLOR_SUPPORT_KEY,
42
+ DIMENSIONS_SUPPORT_KEY,
38
43
  SPACING_SUPPORT_KEY,
39
44
  ];
40
45
 
@@ -98,8 +103,11 @@ const skipSerializationPathsEdit = {
98
103
  [ `${ TYPOGRAPHY_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [
99
104
  TYPOGRAPHY_SUPPORT_KEY,
100
105
  ],
106
+ [ `${ DIMENSIONS_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [
107
+ DIMENSIONS_SUPPORT_KEY,
108
+ ],
101
109
  [ `${ SPACING_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [
102
- 'spacing',
110
+ SPACING_SUPPORT_KEY,
103
111
  ],
104
112
  };
105
113
 
@@ -28,6 +28,9 @@ describe( 'getInlineStyles', () => {
28
28
  style: 'dotted',
29
29
  color: '#21759b',
30
30
  },
31
+ dimensions: {
32
+ minHeight: '50vh',
33
+ },
31
34
  spacing: {
32
35
  blockGap: '1em',
33
36
  padding: { top: '10px' },
@@ -44,6 +47,7 @@ describe( 'getInlineStyles', () => {
44
47
  lineHeight: 1.5,
45
48
  fontSize: 10,
46
49
  marginBottom: '15px',
50
+ minHeight: '50vh',
47
51
  paddingTop: '10px',
48
52
  } );
49
53
  } );
@@ -42,7 +42,7 @@ describe( 'getTypographyClassesAndStyles', () => {
42
42
  style: {
43
43
  letterSpacing: '22px',
44
44
  fontSize:
45
- 'clamp(1.5rem, 1.5rem + ((1vw - 0.48rem) * 2.885), 3rem)',
45
+ 'clamp(1.5rem, 1.5rem + ((1vw - 0.48rem) * 0.962), 2rem)',
46
46
  textTransform: 'uppercase',
47
47
  },
48
48
  } );