@wordpress/edit-site 4.10.0 → 4.12.1-next.d6164808d3.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 (204) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-template/add-custom-template-modal.js +26 -44
  3. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  4. package/build/components/add-new-template/new-template.js +45 -23
  5. package/build/components/add-new-template/new-template.js.map +1 -1
  6. package/build/components/add-new-template/utils.js +493 -242
  7. package/build/components/add-new-template/utils.js.map +1 -1
  8. package/build/components/block-editor/index.js +1 -3
  9. package/build/components/block-editor/index.js.map +1 -1
  10. package/build/components/block-editor/resizable-editor.js +26 -12
  11. package/build/components/block-editor/resizable-editor.js.map +1 -1
  12. package/build/components/global-styles/border-panel.js +3 -3
  13. package/build/components/global-styles/border-panel.js.map +1 -1
  14. package/build/components/global-styles/dimensions-panel.js +280 -20
  15. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  16. package/build/components/global-styles/hooks.js +4 -4
  17. package/build/components/global-styles/hooks.js.map +1 -1
  18. package/build/components/global-styles/screen-color-palette.js +1 -1
  19. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  20. package/build/components/global-styles/screen-colors.js +51 -7
  21. package/build/components/global-styles/screen-colors.js.map +1 -1
  22. package/build/components/global-styles/screen-heading-color.js +157 -0
  23. package/build/components/global-styles/screen-heading-color.js.map +1 -0
  24. package/build/components/global-styles/screen-typography-element.js +4 -0
  25. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  26. package/build/components/global-styles/screen-typography.js +5 -0
  27. package/build/components/global-styles/screen-typography.js.map +1 -1
  28. package/build/components/global-styles/typography-panel.js +82 -14
  29. package/build/components/global-styles/typography-panel.js.map +1 -1
  30. package/build/components/global-styles/typography-utils.js +217 -0
  31. package/build/components/global-styles/typography-utils.js.map +1 -0
  32. package/build/components/global-styles/ui.js +11 -0
  33. package/build/components/global-styles/ui.js.map +1 -1
  34. package/build/components/global-styles/use-global-styles-output.js +183 -52
  35. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  36. package/build/components/global-styles/utils.js +85 -5
  37. package/build/components/global-styles/utils.js.map +1 -1
  38. package/build/components/header/document-actions/index.js +1 -0
  39. package/build/components/header/document-actions/index.js.map +1 -1
  40. package/build/components/header/index.js +27 -12
  41. package/build/components/header/index.js.map +1 -1
  42. package/build/components/header/mode-switcher/index.js +0 -4
  43. package/build/components/header/mode-switcher/index.js.map +1 -1
  44. package/build/components/header/more-menu/index.js +13 -3
  45. package/build/components/header/more-menu/index.js.map +1 -1
  46. package/build/components/header/undo-redo/redo.js +2 -1
  47. package/build/components/header/undo-redo/redo.js.map +1 -1
  48. package/build/components/list/actions/index.js +1 -1
  49. package/build/components/list/actions/index.js.map +1 -1
  50. package/build/components/save-button/index.js +2 -3
  51. package/build/components/save-button/index.js.map +1 -1
  52. package/build/components/sidebar/default-sidebar.js +11 -1
  53. package/build/components/sidebar/default-sidebar.js.map +1 -1
  54. package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +2 -2
  55. package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
  56. package/build/components/sidebar/plugin-sidebar/index.js +11 -1
  57. package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
  58. package/build/components/sidebar/template-card/template-actions.js +1 -1
  59. package/build/components/sidebar/template-card/template-actions.js.map +1 -1
  60. package/build/components/template-details/edit-template-title.js +1 -1
  61. package/build/components/template-details/edit-template-title.js.map +1 -1
  62. package/build/components/template-details/index.js +19 -9
  63. package/build/components/template-details/index.js.map +1 -1
  64. package/build/components/template-details/template-areas.js +1 -1
  65. package/build/components/template-details/template-areas.js.map +1 -1
  66. package/build/components/template-details/template-part-area-selector.js +47 -0
  67. package/build/components/template-details/template-part-area-selector.js.map +1 -0
  68. package/build/components/template-part-converter/convert-to-template-part.js +4 -1
  69. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  70. package/build/hooks/index.js +2 -0
  71. package/build/hooks/index.js.map +1 -1
  72. package/build/hooks/template-part-edit.js +86 -0
  73. package/build/hooks/template-part-edit.js.map +1 -0
  74. package/build/index.js +1 -1
  75. package/build/index.js.map +1 -1
  76. package/build-module/components/add-new-template/add-custom-template-modal.js +27 -45
  77. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  78. package/build-module/components/add-new-template/new-template.js +45 -25
  79. package/build-module/components/add-new-template/new-template.js.map +1 -1
  80. package/build-module/components/add-new-template/utils.js +489 -230
  81. package/build-module/components/add-new-template/utils.js.map +1 -1
  82. package/build-module/components/block-editor/index.js +1 -2
  83. package/build-module/components/block-editor/index.js.map +1 -1
  84. package/build-module/components/block-editor/resizable-editor.js +26 -12
  85. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  86. package/build-module/components/global-styles/border-panel.js +3 -3
  87. package/build-module/components/global-styles/border-panel.js.map +1 -1
  88. package/build-module/components/global-styles/dimensions-panel.js +278 -22
  89. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  90. package/build-module/components/global-styles/hooks.js +4 -4
  91. package/build-module/components/global-styles/hooks.js.map +1 -1
  92. package/build-module/components/global-styles/screen-color-palette.js +1 -1
  93. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  94. package/build-module/components/global-styles/screen-colors.js +51 -7
  95. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  96. package/build-module/components/global-styles/screen-heading-color.js +143 -0
  97. package/build-module/components/global-styles/screen-heading-color.js.map +1 -0
  98. package/build-module/components/global-styles/screen-typography-element.js +4 -0
  99. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  100. package/build-module/components/global-styles/screen-typography.js +5 -0
  101. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  102. package/build-module/components/global-styles/typography-panel.js +83 -15
  103. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  104. package/build-module/components/global-styles/typography-utils.js +204 -0
  105. package/build-module/components/global-styles/typography-utils.js.map +1 -0
  106. package/build-module/components/global-styles/ui.js +10 -0
  107. package/build-module/components/global-styles/ui.js.map +1 -1
  108. package/build-module/components/global-styles/use-global-styles-output.js +182 -61
  109. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  110. package/build-module/components/global-styles/utils.js +82 -5
  111. package/build-module/components/global-styles/utils.js.map +1 -1
  112. package/build-module/components/header/document-actions/index.js +1 -0
  113. package/build-module/components/header/document-actions/index.js.map +1 -1
  114. package/build-module/components/header/index.js +30 -14
  115. package/build-module/components/header/index.js.map +1 -1
  116. package/build-module/components/header/mode-switcher/index.js +0 -4
  117. package/build-module/components/header/mode-switcher/index.js.map +1 -1
  118. package/build-module/components/header/more-menu/index.js +13 -3
  119. package/build-module/components/header/more-menu/index.js.map +1 -1
  120. package/build-module/components/header/undo-redo/redo.js +3 -2
  121. package/build-module/components/header/undo-redo/redo.js.map +1 -1
  122. package/build-module/components/list/actions/index.js +1 -1
  123. package/build-module/components/list/actions/index.js.map +1 -1
  124. package/build-module/components/save-button/index.js +3 -4
  125. package/build-module/components/save-button/index.js.map +1 -1
  126. package/build-module/components/sidebar/default-sidebar.js +9 -1
  127. package/build-module/components/sidebar/default-sidebar.js.map +1 -1
  128. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +3 -3
  129. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
  130. package/build-module/components/sidebar/plugin-sidebar/index.js +9 -1
  131. package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
  132. package/build-module/components/sidebar/template-card/template-actions.js +1 -1
  133. package/build-module/components/sidebar/template-card/template-actions.js.map +1 -1
  134. package/build-module/components/template-details/edit-template-title.js +1 -1
  135. package/build-module/components/template-details/edit-template-title.js.map +1 -1
  136. package/build-module/components/template-details/index.js +19 -10
  137. package/build-module/components/template-details/index.js.map +1 -1
  138. package/build-module/components/template-details/template-areas.js +1 -1
  139. package/build-module/components/template-details/template-areas.js.map +1 -1
  140. package/build-module/components/template-details/template-part-area-selector.js +35 -0
  141. package/build-module/components/template-details/template-part-area-selector.js.map +1 -0
  142. package/build-module/components/template-part-converter/convert-to-template-part.js +3 -1
  143. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  144. package/build-module/hooks/index.js +1 -0
  145. package/build-module/hooks/index.js.map +1 -1
  146. package/build-module/hooks/template-part-edit.js +67 -0
  147. package/build-module/hooks/template-part-edit.js.map +1 -0
  148. package/build-module/index.js +1 -1
  149. package/build-module/index.js.map +1 -1
  150. package/build-style/style-rtl.css +40 -33
  151. package/build-style/style.css +40 -33
  152. package/package.json +29 -29
  153. package/src/components/add-new-template/add-custom-template-modal.js +39 -48
  154. package/src/components/add-new-template/new-template.js +50 -58
  155. package/src/components/add-new-template/style.scss +20 -8
  156. package/src/components/add-new-template/utils.js +529 -231
  157. package/src/components/block-editor/index.js +0 -2
  158. package/src/components/block-editor/resizable-editor.js +28 -18
  159. package/src/components/editor/style.scss +1 -0
  160. package/src/components/global-styles/border-panel.js +3 -3
  161. package/src/components/global-styles/dimensions-panel.js +344 -45
  162. package/src/components/global-styles/hooks.js +6 -3
  163. package/src/components/global-styles/screen-color-palette.js +1 -1
  164. package/src/components/global-styles/screen-colors.js +46 -4
  165. package/src/components/global-styles/screen-heading-color.js +201 -0
  166. package/src/components/global-styles/screen-typography-element.js +4 -0
  167. package/src/components/global-styles/screen-typography.js +6 -0
  168. package/src/components/global-styles/style.scss +14 -6
  169. package/src/components/global-styles/test/typography-utils.js +130 -0
  170. package/src/components/global-styles/test/use-global-styles-output.js +143 -4
  171. package/src/components/global-styles/test/utils.js +68 -8
  172. package/src/components/global-styles/typography-panel.js +119 -48
  173. package/src/components/global-styles/typography-utils.js +228 -0
  174. package/src/components/global-styles/ui.js +13 -0
  175. package/src/components/global-styles/use-global-styles-output.js +203 -53
  176. package/src/components/global-styles/utils.js +70 -4
  177. package/src/components/header/document-actions/index.js +3 -0
  178. package/src/components/header/index.js +41 -14
  179. package/src/components/header/mode-switcher/index.js +0 -3
  180. package/src/components/header/more-menu/index.js +7 -2
  181. package/src/components/header/style.scss +5 -3
  182. package/src/components/header/undo-redo/redo.js +6 -2
  183. package/src/components/list/actions/index.js +3 -1
  184. package/src/components/save-button/index.js +10 -13
  185. package/src/components/sidebar/default-sidebar.js +12 -0
  186. package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +1 -5
  187. package/src/components/sidebar/plugin-sidebar/index.js +12 -0
  188. package/src/components/sidebar/style.scss +4 -0
  189. package/src/components/sidebar/template-card/template-actions.js +3 -1
  190. package/src/components/template-details/edit-template-title.js +7 -3
  191. package/src/components/template-details/index.js +23 -8
  192. package/src/components/template-details/style.scss +0 -5
  193. package/src/components/template-details/template-areas.js +3 -1
  194. package/src/components/template-details/template-part-area-selector.js +38 -0
  195. package/src/components/template-part-converter/convert-to-template-part.js +3 -1
  196. package/src/hooks/index.js +1 -0
  197. package/src/hooks/template-part-edit.js +82 -0
  198. package/src/index.js +1 -1
  199. package/src/style.scss +0 -1
  200. package/build/components/edit-template-part-menu-button/index.js +0 -90
  201. package/build/components/edit-template-part-menu-button/index.js.map +0 -1
  202. package/build-module/components/edit-template-part-menu-button/index.js +0 -72
  203. package/build-module/components/edit-template-part-menu-button/index.js.map +0 -1
  204. package/src/components/edit-template-part-menu-button/index.js +0 -82
@@ -38,7 +38,6 @@ import NavigateToLink from '../navigate-to-link';
38
38
  import { SidebarInspectorFill } from '../sidebar';
39
39
  import { store as editSiteStore } from '../../store';
40
40
  import BlockInspectorButton from './block-inspector-button';
41
- import EditTemplatePartMenuButton from '../edit-template-part-menu-button';
42
41
  import BackButton from './back-button';
43
42
  import ResizableEditor from './resizable-editor';
44
43
 
@@ -155,7 +154,6 @@ export default function BlockEditor( { setIsInserterOpen } ) {
155
154
  onChange={ onChange }
156
155
  useSubRegistry={ false }
157
156
  >
158
- <EditTemplatePartMenuButton />
159
157
  <TemplatePartConverter />
160
158
  <__experimentalLinkControl.ViewerFill>
161
159
  { useCallback(
@@ -57,20 +57,31 @@ function ResizableEditor( { enableResizing, settings, children, ...props } ) {
57
57
  return;
58
58
  }
59
59
 
60
- let animationFrame = null;
60
+ let timeoutId = null;
61
61
 
62
62
  function resizeHeight() {
63
- if ( ! animationFrame ) {
64
- // Throttle the updates on animation frame.
65
- animationFrame = iframe.contentWindow.requestAnimationFrame(
66
- () => {
67
- setHeight(
68
- iframe.contentDocument.documentElement
69
- .scrollHeight
70
- );
71
- animationFrame = null;
63
+ if ( ! timeoutId ) {
64
+ // Throttle the updates on timeout. This code previously
65
+ // used `requestAnimationFrame`, but that seems to not
66
+ // always work before an iframe is ready.
67
+ timeoutId = iframe.contentWindow.setTimeout( () => {
68
+ const { readyState } = iframe.contentDocument;
69
+
70
+ // Continue deferring the timeout until the document is ready.
71
+ // Only then will it have a height.
72
+ if (
73
+ readyState !== 'interactive' &&
74
+ readyState !== 'complete'
75
+ ) {
76
+ resizeHeight();
77
+ return;
72
78
  }
73
- );
79
+
80
+ setHeight( iframe.contentDocument.body.scrollHeight );
81
+ timeoutId = null;
82
+
83
+ // 30 frames per second.
84
+ }, 1000 / 30 );
74
85
  }
75
86
  }
76
87
 
@@ -82,11 +93,10 @@ function ResizableEditor( { enableResizing, settings, children, ...props } ) {
82
93
  resizeObserver = new iframe.contentWindow.ResizeObserver(
83
94
  resizeHeight
84
95
  );
85
- // Observing the <html> rather than the <body> because the latter
86
- // gets destroyed and remounted after initialization in <Iframe>.
87
- resizeObserver.observe(
88
- iframe.contentDocument.documentElement
89
- );
96
+
97
+ // Observe the body, since the `html` element seems to always
98
+ // have a height of `100%`.
99
+ resizeObserver.observe( iframe.contentDocument.body );
90
100
 
91
101
  resizeHeight();
92
102
  }
@@ -97,7 +107,7 @@ function ResizableEditor( { enableResizing, settings, children, ...props } ) {
97
107
  registerObserver();
98
108
 
99
109
  return () => {
100
- iframe.contentWindow?.cancelAnimationFrame( animationFrame );
110
+ iframe.contentWindow?.clearTimeout( timeoutId );
101
111
  resizeObserver?.disconnect();
102
112
  iframe.removeEventListener( 'load', registerObserver );
103
113
  };
@@ -153,7 +163,7 @@ function ResizableEditor( { enableResizing, settings, children, ...props } ) {
153
163
  } }
154
164
  >
155
165
  <Iframe
156
- style={ enableResizing ? undefined : deviceStyles }
166
+ style={ enableResizing ? { height } : deviceStyles }
157
167
  head={
158
168
  <>
159
169
  <EditorStyles styles={ settings.styles } />
@@ -32,6 +32,7 @@ html.wp-toolbar {
32
32
  position: relative;
33
33
  height: 100%;
34
34
  display: block;
35
+ overflow: hidden;
35
36
 
36
37
  iframe {
37
38
  display: block;
@@ -179,11 +179,11 @@ export default function BorderPanel( { name } ) {
179
179
  <BorderBoxControl
180
180
  colors={ colors }
181
181
  enableAlpha={ true }
182
+ enableStyle={ showBorderStyle }
182
183
  onChange={ onBorderChange }
183
- showStyle={ showBorderStyle }
184
- value={ border }
185
- popoverPlacement="left-start"
186
184
  popoverOffset={ 40 }
185
+ popoverPlacement="left-start"
186
+ value={ border }
187
187
  __experimentalHasMultipleOrigins={ true }
188
188
  __experimentalIsRenderedInSidebar={ true }
189
189
  />
@@ -1,3 +1,8 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classnames from 'classnames';
5
+
1
6
  /**
2
7
  * WordPress dependencies
3
8
  */
@@ -6,10 +11,16 @@ import {
6
11
  __experimentalToolsPanel as ToolsPanel,
7
12
  __experimentalToolsPanelItem as ToolsPanelItem,
8
13
  __experimentalBoxControl as BoxControl,
14
+ __experimentalHStack as HStack,
9
15
  __experimentalUnitControl as UnitControl,
10
16
  __experimentalUseCustomUnits as useCustomUnits,
17
+ __experimentalView as View,
11
18
  } from '@wordpress/components';
12
- import { __experimentalUseCustomSides as useCustomSides } from '@wordpress/block-editor';
19
+ import {
20
+ __experimentalUseCustomSides as useCustomSides,
21
+ __experimentalSpacingSizesControl as SpacingSizesControl,
22
+ } from '@wordpress/block-editor';
23
+ import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
13
24
 
14
25
  /**
15
26
  * Internal dependencies
@@ -19,11 +30,27 @@ import { getSupportedGlobalStylesPanels, useSetting, useStyle } from './hooks';
19
30
  const AXIAL_SIDES = [ 'horizontal', 'vertical' ];
20
31
 
21
32
  export function useHasDimensionsPanel( name ) {
33
+ const hasContentSize = useHasContentSize( name );
34
+ const hasWideSize = useHasWideSize( name );
22
35
  const hasPadding = useHasPadding( name );
23
36
  const hasMargin = useHasMargin( name );
24
37
  const hasGap = useHasGap( name );
25
38
 
26
- return hasPadding || hasMargin || hasGap;
39
+ return hasContentSize || hasWideSize || hasPadding || hasMargin || hasGap;
40
+ }
41
+
42
+ function useHasContentSize( name ) {
43
+ const supports = getSupportedGlobalStylesPanels( name );
44
+ const [ settings ] = useSetting( 'layout.contentSize', name );
45
+
46
+ return settings && supports.includes( 'contentSize' );
47
+ }
48
+
49
+ function useHasWideSize( name ) {
50
+ const supports = getSupportedGlobalStylesPanels( name );
51
+ const [ settings ] = useSetting( 'layout.wideSize', name );
52
+
53
+ return settings && supports.includes( 'wideSize' );
27
54
  }
28
55
 
29
56
  function useHasPadding( name ) {
@@ -47,6 +74,12 @@ function useHasGap( name ) {
47
74
  return settings && supports.includes( 'blockGap' );
48
75
  }
49
76
 
77
+ function useHasSpacingPresets() {
78
+ const [ settings ] = useSetting( 'spacing.spacingSizes' );
79
+
80
+ return settings && settings.length > 0;
81
+ }
82
+
50
83
  function filterValuesBySides( values, sides ) {
51
84
  if ( ! sides ) {
52
85
  // If no custom side configuration all sides are opted into by default.
@@ -71,7 +104,7 @@ function filterValuesBySides( values, sides ) {
71
104
  }
72
105
 
73
106
  function splitStyleValue( value ) {
74
- // Check for shorthand value ( a string value ).
107
+ // Check for shorthand value (a string value).
75
108
  if ( value && typeof value === 'string' ) {
76
109
  // Convert to value for individual sides for BoxControl.
77
110
  return {
@@ -85,20 +118,69 @@ function splitStyleValue( value ) {
85
118
  return value;
86
119
  }
87
120
 
88
- export default function DimensionsPanel( { name } ) {
89
- const showPaddingControl = useHasPadding( name );
90
- const showMarginControl = useHasMargin( name );
91
- const showGapControl = useHasGap( name );
92
- const units = useCustomUnits( {
93
- availableUnits: useSetting( 'spacing.units', name )[ 0 ] || [
94
- '%',
95
- 'px',
96
- 'em',
97
- 'rem',
98
- 'vw',
99
- ],
100
- } );
121
+ function splitGapValue( value ) {
122
+ // Check for shorthand value (a string value).
123
+ if ( value && typeof value === 'string' ) {
124
+ // Convert to value for individual sides for BoxControl.
125
+ return {
126
+ top: value,
127
+ right: value,
128
+ bottom: value,
129
+ left: value,
130
+ };
131
+ }
132
+
133
+ return {
134
+ ...value,
135
+ right: value?.left,
136
+ bottom: value?.top,
137
+ };
138
+ }
139
+
140
+ // Props for managing `layout.contentSize`.
141
+ function useContentSizeProps( name ) {
142
+ const [ contentSizeValue, setContentSizeValue ] = useSetting(
143
+ 'layout.contentSize',
144
+ name
145
+ );
146
+ const [ userSetContentSizeValue ] = useSetting(
147
+ 'layout.contentSize',
148
+ name,
149
+ 'user'
150
+ );
151
+ const hasUserSetContentSizeValue = () => !! userSetContentSizeValue;
152
+ const resetContentSizeValue = () => setContentSizeValue( '' );
153
+ return {
154
+ contentSizeValue,
155
+ setContentSizeValue,
156
+ hasUserSetContentSizeValue,
157
+ resetContentSizeValue,
158
+ };
159
+ }
101
160
 
161
+ // Props for managing `layout.wideSize`.
162
+ function useWideSizeProps( name ) {
163
+ const [ wideSizeValue, setWideSizeValue ] = useSetting(
164
+ 'layout.wideSize',
165
+ name
166
+ );
167
+ const [ userSetWideSizeValue ] = useSetting(
168
+ 'layout.wideSize',
169
+ name,
170
+ 'user'
171
+ );
172
+ const hasUserSetWideSizeValue = () => !! userSetWideSizeValue;
173
+ const resetWideSizeValue = () => setWideSizeValue( '' );
174
+ return {
175
+ wideSizeValue,
176
+ setWideSizeValue,
177
+ hasUserSetWideSizeValue,
178
+ resetWideSizeValue,
179
+ };
180
+ }
181
+
182
+ // Props for managing `spacing.padding`.
183
+ function usePaddingProps( name ) {
102
184
  const [ rawPadding, setRawPadding ] = useStyle( 'spacing.padding', name );
103
185
  const paddingValues = splitStyleValue( rawPadding );
104
186
  const paddingSides = useCustomSides( name, 'padding' );
@@ -111,9 +193,22 @@ export default function DimensionsPanel( { name } ) {
111
193
  setRawPadding( padding );
112
194
  };
113
195
  const resetPaddingValue = () => setPaddingValues( {} );
114
- const hasPaddingValue = () =>
115
- !! paddingValues && Object.keys( paddingValues ).length;
196
+ const [ userSetPaddingValue ] = useStyle( 'spacing.padding', name, 'user' );
197
+ // The `hasPaddingValue` check does not need a parsed value, as `userSetPaddingValue` will be `undefined` if not set.
198
+ const hasPaddingValue = () => !! userSetPaddingValue;
199
+
200
+ return {
201
+ paddingValues,
202
+ paddingSides,
203
+ isAxialPadding,
204
+ setPaddingValues,
205
+ resetPaddingValue,
206
+ hasPaddingValue,
207
+ };
208
+ }
116
209
 
210
+ // Props for managing `spacing.margin`.
211
+ function useMarginProps( name ) {
117
212
  const [ rawMargin, setRawMargin ] = useStyle( 'spacing.margin', name );
118
213
  const marginValues = splitStyleValue( rawMargin );
119
214
  const marginSides = useCustomSides( name, 'margin' );
@@ -129,34 +224,209 @@ export default function DimensionsPanel( { name } ) {
129
224
  const hasMarginValue = () =>
130
225
  !! marginValues && Object.keys( marginValues ).length;
131
226
 
227
+ return {
228
+ marginValues,
229
+ marginSides,
230
+ isAxialMargin,
231
+ setMarginValues,
232
+ resetMarginValue,
233
+ hasMarginValue,
234
+ };
235
+ }
236
+
237
+ // Props for managing `spacing.blockGap`.
238
+ function useBlockGapProps( name ) {
132
239
  const [ gapValue, setGapValue ] = useStyle( 'spacing.blockGap', name );
240
+ const gapValues = splitGapValue( gapValue );
241
+ const setGapValues = ( nextBoxGapValue ) => {
242
+ if ( ! nextBoxGapValue ) {
243
+ setGapValue( null );
244
+ }
245
+ setGapValue( {
246
+ top: nextBoxGapValue?.top,
247
+ left: nextBoxGapValue?.left,
248
+ } );
249
+ };
250
+ const gapSides = useCustomSides( name, 'blockGap' );
251
+ const isAxialGap =
252
+ gapSides && gapSides.some( ( side ) => AXIAL_SIDES.includes( side ) );
133
253
  const resetGapValue = () => setGapValue( undefined );
134
- const hasGapValue = () => !! gapValue;
254
+ const [ userSetGapValue ] = useStyle( 'spacing.blockGap', name, 'user' );
255
+ const hasGapValue = () => !! userSetGapValue;
256
+ return {
257
+ gapValue,
258
+ gapValues,
259
+ gapSides,
260
+ isAxialGap,
261
+ setGapValue,
262
+ setGapValues,
263
+ resetGapValue,
264
+ hasGapValue,
265
+ };
266
+ }
267
+
268
+ export default function DimensionsPanel( { name } ) {
269
+ const showContentSizeControl = useHasContentSize( name );
270
+ const showWideSizeControl = useHasWideSize( name );
271
+ const showPaddingControl = useHasPadding( name );
272
+ const showMarginControl = useHasMargin( name );
273
+ const showGapControl = useHasGap( name );
274
+ const showSpacingPresetsControl = useHasSpacingPresets();
275
+ const units = useCustomUnits( {
276
+ availableUnits: useSetting( 'spacing.units', name )[ 0 ] || [
277
+ '%',
278
+ 'px',
279
+ 'em',
280
+ 'rem',
281
+ 'vw',
282
+ ],
283
+ } );
284
+
285
+ // Props for managing `layout.contentSize`.
286
+ const {
287
+ contentSizeValue,
288
+ setContentSizeValue,
289
+ hasUserSetContentSizeValue,
290
+ resetContentSizeValue,
291
+ } = useContentSizeProps( name );
292
+
293
+ // Props for managing `layout.wideSize`.
294
+ const {
295
+ wideSizeValue,
296
+ setWideSizeValue,
297
+ hasUserSetWideSizeValue,
298
+ resetWideSizeValue,
299
+ } = useWideSizeProps( name );
300
+
301
+ // Props for managing `spacing.padding`.
302
+ const {
303
+ paddingValues,
304
+ paddingSides,
305
+ isAxialPadding,
306
+ setPaddingValues,
307
+ resetPaddingValue,
308
+ hasPaddingValue,
309
+ } = usePaddingProps( name );
310
+
311
+ // Props for managing `spacing.margin`.
312
+ const {
313
+ marginValues,
314
+ marginSides,
315
+ isAxialMargin,
316
+ setMarginValues,
317
+ resetMarginValue,
318
+ hasMarginValue,
319
+ } = useMarginProps( name );
320
+
321
+ // Props for managing `spacing.blockGap`.
322
+ const {
323
+ gapValue,
324
+ gapValues,
325
+ gapSides,
326
+ isAxialGap,
327
+ setGapValue,
328
+ setGapValues,
329
+ resetGapValue,
330
+ hasGapValue,
331
+ } = useBlockGapProps( name );
135
332
 
136
333
  const resetAll = () => {
137
334
  resetPaddingValue();
138
335
  resetMarginValue();
139
336
  resetGapValue();
337
+ resetContentSizeValue();
338
+ resetWideSizeValue();
140
339
  };
141
340
 
142
341
  return (
143
342
  <ToolsPanel label={ __( 'Dimensions' ) } resetAll={ resetAll }>
343
+ { ( showContentSizeControl || showWideSizeControl ) && (
344
+ <span className="span-columns">
345
+ { __( 'Set the width of the main content area.' ) }
346
+ </span>
347
+ ) }
348
+ { showContentSizeControl && (
349
+ <ToolsPanelItem
350
+ className="single-column"
351
+ label={ __( 'Content size' ) }
352
+ hasValue={ hasUserSetContentSizeValue }
353
+ onDeselect={ resetContentSizeValue }
354
+ isShownByDefault={ true }
355
+ >
356
+ <HStack alignment="flex-end" justify="flex-start">
357
+ <UnitControl
358
+ label={ __( 'Content' ) }
359
+ labelPosition="top"
360
+ __unstableInputWidth="80px"
361
+ value={ contentSizeValue || '' }
362
+ onChange={ ( nextContentSize ) => {
363
+ setContentSizeValue( nextContentSize );
364
+ } }
365
+ units={ units }
366
+ />
367
+ <View>
368
+ <Icon icon={ positionCenter } />
369
+ </View>
370
+ </HStack>
371
+ </ToolsPanelItem>
372
+ ) }
373
+ { showWideSizeControl && (
374
+ <ToolsPanelItem
375
+ className="single-column"
376
+ label={ __( 'Wide size' ) }
377
+ hasValue={ hasUserSetWideSizeValue }
378
+ onDeselect={ resetWideSizeValue }
379
+ isShownByDefault={ true }
380
+ >
381
+ <HStack alignment="flex-end" justify="flex-start">
382
+ <UnitControl
383
+ label={ __( 'Wide' ) }
384
+ labelPosition="top"
385
+ __unstableInputWidth="80px"
386
+ value={ wideSizeValue || '' }
387
+ onChange={ ( nextWideSize ) => {
388
+ setWideSizeValue( nextWideSize );
389
+ } }
390
+ units={ units }
391
+ />
392
+ <View>
393
+ <Icon icon={ stretchWide } />
394
+ </View>
395
+ </HStack>
396
+ </ToolsPanelItem>
397
+ ) }
144
398
  { showPaddingControl && (
145
399
  <ToolsPanelItem
146
400
  hasValue={ hasPaddingValue }
147
401
  label={ __( 'Padding' ) }
148
402
  onDeselect={ resetPaddingValue }
149
403
  isShownByDefault={ true }
404
+ className={ classnames( {
405
+ 'tools-panel-item-spacing': showSpacingPresetsControl,
406
+ } ) }
150
407
  >
151
- <BoxControl
152
- values={ paddingValues }
153
- onChange={ setPaddingValues }
154
- label={ __( 'Padding' ) }
155
- sides={ paddingSides }
156
- units={ units }
157
- allowReset={ false }
158
- splitOnAxis={ isAxialPadding }
159
- />
408
+ { ! showSpacingPresetsControl && (
409
+ <BoxControl
410
+ values={ paddingValues }
411
+ onChange={ setPaddingValues }
412
+ label={ __( 'Padding' ) }
413
+ sides={ paddingSides }
414
+ units={ units }
415
+ allowReset={ false }
416
+ splitOnAxis={ isAxialPadding }
417
+ />
418
+ ) }
419
+ { showSpacingPresetsControl && (
420
+ <SpacingSizesControl
421
+ values={ paddingValues }
422
+ onChange={ setPaddingValues }
423
+ label={ __( 'Padding' ) }
424
+ sides={ paddingSides }
425
+ units={ units }
426
+ allowReset={ false }
427
+ splitOnAxis={ isAxialPadding }
428
+ />
429
+ ) }
160
430
  </ToolsPanelItem>
161
431
  ) }
162
432
  { showMarginControl && (
@@ -165,16 +435,32 @@ export default function DimensionsPanel( { name } ) {
165
435
  label={ __( 'Margin' ) }
166
436
  onDeselect={ resetMarginValue }
167
437
  isShownByDefault={ true }
438
+ className={ classnames( {
439
+ 'tools-panel-item-spacing': showSpacingPresetsControl,
440
+ } ) }
168
441
  >
169
- <BoxControl
170
- values={ marginValues }
171
- onChange={ setMarginValues }
172
- label={ __( 'Margin' ) }
173
- sides={ marginSides }
174
- units={ units }
175
- allowReset={ false }
176
- splitOnAxis={ isAxialMargin }
177
- />
442
+ { ! showSpacingPresetsControl && (
443
+ <BoxControl
444
+ values={ marginValues }
445
+ onChange={ setMarginValues }
446
+ label={ __( 'Margin' ) }
447
+ sides={ marginSides }
448
+ units={ units }
449
+ allowReset={ false }
450
+ splitOnAxis={ isAxialMargin }
451
+ />
452
+ ) }
453
+ { showSpacingPresetsControl && (
454
+ <SpacingSizesControl
455
+ values={ marginValues }
456
+ onChange={ setMarginValues }
457
+ label={ __( 'Margin' ) }
458
+ sides={ marginSides }
459
+ units={ units }
460
+ allowReset={ false }
461
+ splitOnAxis={ isAxialMargin }
462
+ />
463
+ ) }
178
464
  </ToolsPanelItem>
179
465
  ) }
180
466
  { showGapControl && (
@@ -184,14 +470,27 @@ export default function DimensionsPanel( { name } ) {
184
470
  onDeselect={ resetGapValue }
185
471
  isShownByDefault={ true }
186
472
  >
187
- <UnitControl
188
- label={ __( 'Block spacing' ) }
189
- __unstableInputWidth="80px"
190
- min={ 0 }
191
- onChange={ setGapValue }
192
- units={ units }
193
- value={ gapValue }
194
- />
473
+ { isAxialGap ? (
474
+ <BoxControl
475
+ label={ __( 'Block spacing' ) }
476
+ min={ 0 }
477
+ onChange={ setGapValues }
478
+ units={ units }
479
+ sides={ gapSides }
480
+ values={ gapValues }
481
+ allowReset={ false }
482
+ splitOnAxis={ isAxialGap }
483
+ />
484
+ ) : (
485
+ <UnitControl
486
+ label={ __( 'Block spacing' ) }
487
+ __unstableInputWidth="80px"
488
+ min={ 0 }
489
+ onChange={ setGapValue }
490
+ units={ units }
491
+ value={ gapValue }
492
+ />
493
+ ) }
195
494
  </ToolsPanelItem>
196
495
  ) }
197
496
  </ToolsPanel>
@@ -128,21 +128,21 @@ export function useStyle( path, blockName, source = 'all' ) {
128
128
  switch ( source ) {
129
129
  case 'all':
130
130
  result = getValueFromVariable(
131
- mergedConfig.settings,
131
+ mergedConfig,
132
132
  blockName,
133
133
  get( userConfig, finalPath ) ?? get( baseConfig, finalPath )
134
134
  );
135
135
  break;
136
136
  case 'user':
137
137
  result = getValueFromVariable(
138
- mergedConfig.settings,
138
+ mergedConfig,
139
139
  blockName,
140
140
  get( userConfig, finalPath )
141
141
  );
142
142
  break;
143
143
  case 'base':
144
144
  result = getValueFromVariable(
145
- baseConfig.settings,
145
+ baseConfig,
146
146
  blockName,
147
147
  get( baseConfig, finalPath )
148
148
  );
@@ -168,6 +168,9 @@ const ROOT_BLOCK_SUPPORTS = [
168
168
  'textDecoration',
169
169
  'textTransform',
170
170
  'padding',
171
+ 'contentSize',
172
+ 'wideSize',
173
+ 'blockGap',
171
174
  ];
172
175
 
173
176
  export function getSupportedGlobalStylesPanels( name ) {
@@ -24,7 +24,7 @@ function ScreenColorPalette( { name } ) {
24
24
  tabs={ [
25
25
  {
26
26
  name: 'solid',
27
- title: 'Solid color',
27
+ title: 'Solid',
28
28
  value: 'solid',
29
29
  },
30
30
  {