@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.
- package/CHANGELOG.md +4 -0
- package/build/components/add-new-template/add-custom-template-modal.js +26 -44
- package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build/components/add-new-template/new-template.js +45 -23
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +493 -242
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/block-editor/index.js +1 -3
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/block-editor/resizable-editor.js +26 -12
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/global-styles/border-panel.js +3 -3
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +280 -20
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +4 -4
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/screen-color-palette.js +1 -1
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +51 -7
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +157 -0
- package/build/components/global-styles/screen-heading-color.js.map +1 -0
- package/build/components/global-styles/screen-typography-element.js +4 -0
- package/build/components/global-styles/screen-typography-element.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +5 -0
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +82 -14
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +217 -0
- package/build/components/global-styles/typography-utils.js.map +1 -0
- package/build/components/global-styles/ui.js +11 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +183 -52
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +85 -5
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/header/document-actions/index.js +1 -0
- package/build/components/header/document-actions/index.js.map +1 -1
- package/build/components/header/index.js +27 -12
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js +0 -4
- package/build/components/header/mode-switcher/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +13 -3
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/undo-redo/redo.js +2 -1
- package/build/components/header/undo-redo/redo.js.map +1 -1
- package/build/components/list/actions/index.js +1 -1
- package/build/components/list/actions/index.js.map +1 -1
- package/build/components/save-button/index.js +2 -3
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/sidebar/default-sidebar.js +11 -1
- package/build/components/sidebar/default-sidebar.js.map +1 -1
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +2 -2
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js +11 -1
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build/components/sidebar/template-card/template-actions.js +1 -1
- package/build/components/sidebar/template-card/template-actions.js.map +1 -1
- package/build/components/template-details/edit-template-title.js +1 -1
- package/build/components/template-details/edit-template-title.js.map +1 -1
- package/build/components/template-details/index.js +19 -9
- package/build/components/template-details/index.js.map +1 -1
- package/build/components/template-details/template-areas.js +1 -1
- package/build/components/template-details/template-areas.js.map +1 -1
- package/build/components/template-details/template-part-area-selector.js +47 -0
- package/build/components/template-details/template-part-area-selector.js.map +1 -0
- package/build/components/template-part-converter/convert-to-template-part.js +4 -1
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/template-part-edit.js +86 -0
- package/build/hooks/template-part-edit.js.map +1 -0
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js +27 -45
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +45 -25
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +489 -230
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/block-editor/index.js +1 -2
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/block-editor/resizable-editor.js +26 -12
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -3
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +278 -22
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +4 -4
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/screen-color-palette.js +1 -1
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +51 -7
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +143 -0
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -0
- package/build-module/components/global-styles/screen-typography-element.js +4 -0
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +5 -0
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +83 -15
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +204 -0
- package/build-module/components/global-styles/typography-utils.js.map +1 -0
- package/build-module/components/global-styles/ui.js +10 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +182 -61
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +82 -5
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/header/document-actions/index.js +1 -0
- package/build-module/components/header/document-actions/index.js.map +1 -1
- package/build-module/components/header/index.js +30 -14
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js +0 -4
- package/build-module/components/header/mode-switcher/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +13 -3
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/undo-redo/redo.js +3 -2
- package/build-module/components/header/undo-redo/redo.js.map +1 -1
- package/build-module/components/list/actions/index.js +1 -1
- package/build-module/components/list/actions/index.js.map +1 -1
- package/build-module/components/save-button/index.js +3 -4
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/sidebar/default-sidebar.js +9 -1
- package/build-module/components/sidebar/default-sidebar.js.map +1 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +3 -3
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +9 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/template-card/template-actions.js +1 -1
- package/build-module/components/sidebar/template-card/template-actions.js.map +1 -1
- package/build-module/components/template-details/edit-template-title.js +1 -1
- package/build-module/components/template-details/edit-template-title.js.map +1 -1
- package/build-module/components/template-details/index.js +19 -10
- package/build-module/components/template-details/index.js.map +1 -1
- package/build-module/components/template-details/template-areas.js +1 -1
- package/build-module/components/template-details/template-areas.js.map +1 -1
- package/build-module/components/template-details/template-part-area-selector.js +35 -0
- package/build-module/components/template-details/template-part-area-selector.js.map +1 -0
- package/build-module/components/template-part-converter/convert-to-template-part.js +3 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/template-part-edit.js +67 -0
- package/build-module/hooks/template-part-edit.js.map +1 -0
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-style/style-rtl.css +40 -33
- package/build-style/style.css +40 -33
- package/package.json +29 -29
- package/src/components/add-new-template/add-custom-template-modal.js +39 -48
- package/src/components/add-new-template/new-template.js +50 -58
- package/src/components/add-new-template/style.scss +20 -8
- package/src/components/add-new-template/utils.js +529 -231
- package/src/components/block-editor/index.js +0 -2
- package/src/components/block-editor/resizable-editor.js +28 -18
- package/src/components/editor/style.scss +1 -0
- package/src/components/global-styles/border-panel.js +3 -3
- package/src/components/global-styles/dimensions-panel.js +344 -45
- package/src/components/global-styles/hooks.js +6 -3
- package/src/components/global-styles/screen-color-palette.js +1 -1
- package/src/components/global-styles/screen-colors.js +46 -4
- package/src/components/global-styles/screen-heading-color.js +201 -0
- package/src/components/global-styles/screen-typography-element.js +4 -0
- package/src/components/global-styles/screen-typography.js +6 -0
- package/src/components/global-styles/style.scss +14 -6
- package/src/components/global-styles/test/typography-utils.js +130 -0
- package/src/components/global-styles/test/use-global-styles-output.js +143 -4
- package/src/components/global-styles/test/utils.js +68 -8
- package/src/components/global-styles/typography-panel.js +119 -48
- package/src/components/global-styles/typography-utils.js +228 -0
- package/src/components/global-styles/ui.js +13 -0
- package/src/components/global-styles/use-global-styles-output.js +203 -53
- package/src/components/global-styles/utils.js +70 -4
- package/src/components/header/document-actions/index.js +3 -0
- package/src/components/header/index.js +41 -14
- package/src/components/header/mode-switcher/index.js +0 -3
- package/src/components/header/more-menu/index.js +7 -2
- package/src/components/header/style.scss +5 -3
- package/src/components/header/undo-redo/redo.js +6 -2
- package/src/components/list/actions/index.js +3 -1
- package/src/components/save-button/index.js +10 -13
- package/src/components/sidebar/default-sidebar.js +12 -0
- package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +1 -5
- package/src/components/sidebar/plugin-sidebar/index.js +12 -0
- package/src/components/sidebar/style.scss +4 -0
- package/src/components/sidebar/template-card/template-actions.js +3 -1
- package/src/components/template-details/edit-template-title.js +7 -3
- package/src/components/template-details/index.js +23 -8
- package/src/components/template-details/style.scss +0 -5
- package/src/components/template-details/template-areas.js +3 -1
- package/src/components/template-details/template-part-area-selector.js +38 -0
- package/src/components/template-part-converter/convert-to-template-part.js +3 -1
- package/src/hooks/index.js +1 -0
- package/src/hooks/template-part-edit.js +82 -0
- package/src/index.js +1 -1
- package/src/style.scss +0 -1
- package/build/components/edit-template-part-menu-button/index.js +0 -90
- package/build/components/edit-template-part-menu-button/index.js.map +0 -1
- package/build-module/components/edit-template-part-menu-button/index.js +0 -72
- package/build-module/components/edit-template-part-menu-button/index.js.map +0 -1
- 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
|
|
60
|
+
let timeoutId = null;
|
|
61
61
|
|
|
62
62
|
function resizeHeight() {
|
|
63
|
-
if ( !
|
|
64
|
-
// Throttle the updates on
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
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?.
|
|
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 ?
|
|
166
|
+
style={ enableResizing ? { height } : deviceStyles }
|
|
157
167
|
head={
|
|
158
168
|
<>
|
|
159
169
|
<EditorStyles styles={ settings.styles } />
|
|
@@ -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 {
|
|
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 (
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
|
115
|
-
|
|
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
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
|
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
|
|
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
|
|
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 ) {
|