@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.
- package/CHANGELOG.md +7 -0
- package/README.md +0 -1
- package/build/components/block-lock/menu-item.js +1 -1
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +16 -9
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-styles/utils.js +3 -3
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/index.js +19 -4
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +27 -4
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/colors/with-colors.js +4 -3
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +24 -40
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +7 -5
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +5 -3
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/link-control/index.js +18 -34
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +26 -0
- package/build/components/link-control/use-internal-input-value.js.map +1 -0
- package/build/components/list-view/block.js +5 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -3
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +100 -0
- package/build/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build/components/off-canvas-editor/block-select-button.js +119 -0
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build/components/off-canvas-editor/block.js +292 -0
- package/build/components/off-canvas-editor/block.js.map +1 -0
- package/build/components/off-canvas-editor/branch.js +181 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -0
- package/build/components/off-canvas-editor/context.js +19 -0
- package/build/components/off-canvas-editor/context.js.map +1 -0
- package/build/components/off-canvas-editor/drop-indicator.js +118 -0
- package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build/components/off-canvas-editor/expander.js +41 -0
- package/build/components/off-canvas-editor/expander.js.map +1 -0
- package/build/components/off-canvas-editor/index.js +204 -0
- package/build/components/off-canvas-editor/index.js.map +1 -0
- package/build/components/off-canvas-editor/leaf.js +60 -0
- package/build/components/off-canvas-editor/leaf.js.map +1 -0
- package/build/components/off-canvas-editor/use-block-selection.js +139 -0
- package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build/components/off-canvas-editor/utils.js +60 -0
- package/build/components/off-canvas-editor/utils.js.map +1 -0
- package/build/components/url-popover/index.js +31 -2
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/use-setting/index.js +1 -1
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/color-panel.js +17 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +13 -6
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +44 -13
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/layout.js +2 -2
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +4 -2
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/min-height.js +145 -0
- package/build/hooks/min-height.js.map +1 -0
- package/build/hooks/padding.js +4 -2
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +3 -2
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/flex.js +22 -21
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +26 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +46 -14
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +16 -2
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +2 -2
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +17 -10
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-styles/utils.js +3 -3
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/index.js +19 -4
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +27 -5
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/colors/with-colors.js +5 -4
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +24 -40
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +8 -6
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +5 -3
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/link-control/index.js +17 -34
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +18 -0
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
- package/build-module/components/list-view/block.js +5 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -3
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +85 -0
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block.js +268 -0
- package/build-module/components/off-canvas-editor/block.js.map +1 -0
- package/build-module/components/off-canvas-editor/branch.js +165 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -0
- package/build-module/components/off-canvas-editor/context.js +7 -0
- package/build-module/components/off-canvas-editor/context.js.map +1 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build-module/components/off-canvas-editor/expander.js +32 -0
- package/build-module/components/off-canvas-editor/expander.js.map +1 -0
- package/build-module/components/off-canvas-editor/index.js +181 -0
- package/build-module/components/off-canvas-editor/index.js.map +1 -0
- package/build-module/components/off-canvas-editor/leaf.js +45 -0
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build-module/components/off-canvas-editor/utils.js +44 -0
- package/build-module/components/off-canvas-editor/utils.js.map +1 -0
- package/build-module/components/url-popover/index.js +30 -3
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +1 -1
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/color-panel.js +17 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +15 -8
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +39 -12
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/layout.js +2 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -2
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/min-height.js +122 -0
- package/build-module/hooks/min-height.js.map +1 -0
- package/build-module/hooks/padding.js +4 -2
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +4 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/flex.js +23 -22
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +22 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +44 -14
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +13 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +39 -26
- package/build-style/style.css +39 -26
- package/package.json +28 -28
- package/src/components/alignment-control/README.md +1 -1
- package/src/components/block-alignment-control/test/index.native.js +4 -4
- package/src/components/block-draggable/test/helpers.native.js +3 -3
- package/src/components/block-draggable/test/index.native.js +27 -27
- package/src/components/block-list/style.scss +10 -5
- package/src/components/block-lock/menu-item.js +5 -2
- package/src/components/block-lock/modal.js +19 -36
- package/src/components/block-lock/style.scss +8 -17
- package/src/components/block-mover/style.scss +0 -1
- package/src/components/block-popover/style.scss +1 -1
- package/src/components/block-styles/utils.js +3 -3
- package/src/components/block-switcher/index.js +19 -4
- package/src/components/block-tools/selected-block-popover.js +80 -34
- package/src/components/block-tools/style.scss +15 -0
- package/src/components/colors/with-colors.js +13 -23
- package/src/components/default-block-appender/style.scss +1 -0
- package/src/components/font-sizes/fluid-utils.js +37 -64
- package/src/components/font-sizes/test/fluid-utils.js +5 -5
- package/src/components/font-sizes/with-font-sizes.js +14 -11
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/index.js +7 -4
- package/src/components/inserter/reusable-blocks-tab.js +4 -2
- package/src/components/inserter/style.scss +8 -7
- package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
- package/src/components/link-control/index.js +23 -39
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-control/test/index.js +272 -241
- package/src/components/link-control/use-internal-input-value.js +22 -0
- package/src/components/list-view/block.js +4 -3
- package/src/components/list-view/branch.js +11 -6
- package/src/components/off-canvas-editor/README.md +5 -0
- package/src/components/off-canvas-editor/block-contents.js +89 -0
- package/src/components/off-canvas-editor/block-select-button.js +113 -0
- package/src/components/off-canvas-editor/block.js +335 -0
- package/src/components/off-canvas-editor/branch.js +210 -0
- package/src/components/off-canvas-editor/context.js +8 -0
- package/src/components/off-canvas-editor/drop-indicator.js +126 -0
- package/src/components/off-canvas-editor/expander.js +26 -0
- package/src/components/off-canvas-editor/index.js +216 -0
- package/src/components/off-canvas-editor/leaf.js +48 -0
- package/src/components/off-canvas-editor/style.scss +397 -0
- package/src/components/off-canvas-editor/test/utils.js +50 -0
- package/src/components/off-canvas-editor/use-block-selection.js +169 -0
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
- package/src/components/off-canvas-editor/utils.js +58 -0
- package/src/components/responsive-block-control/test/index.js +69 -92
- package/src/components/url-popover/README.md +12 -3
- package/src/components/url-popover/index.js +33 -3
- package/src/components/use-setting/index.js +7 -1
- package/src/hooks/color-panel.js +13 -1
- package/src/hooks/color.js +2 -0
- package/src/hooks/content-lock-ui.js +46 -34
- package/src/hooks/dimensions.js +76 -16
- package/src/hooks/layout.js +2 -3
- package/src/hooks/margin.js +4 -3
- package/src/hooks/min-height.js +121 -0
- package/src/hooks/padding.js +4 -3
- package/src/hooks/style.js +10 -2
- package/src/hooks/test/style.js +4 -0
- package/src/hooks/test/use-typography-props.js +1 -1
- package/src/layouts/flex.js +43 -38
- package/src/store/actions.js +22 -0
- package/src/store/reducer.js +50 -40
- package/src/store/selectors.js +16 -9
- package/src/store/test/actions.js +18 -0
- package/src/store/test/reducer.js +40 -0
- 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 {
|
|
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
|
-
|
|
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
|
-
|
|
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 = [
|
|
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,
|
package/src/hooks/color-panel.js
CHANGED
|
@@ -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
|
|
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
|
|
package/src/hooks/color.js
CHANGED
|
@@ -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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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(
|
package/src/hooks/dimensions.js
CHANGED
|
@@ -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
|
|
50
|
-
|
|
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 =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
|
251
|
+
return (
|
|
252
|
+
gapDisabled && minHeightDisabled && paddingDisabled && marginDisabled
|
|
253
|
+
);
|
|
194
254
|
};
|
|
195
255
|
|
|
196
256
|
/**
|
package/src/hooks/layout.js
CHANGED
|
@@ -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
|
|
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={
|
|
412
|
+
__unstableLayoutClassNames={ layoutClassNames }
|
|
414
413
|
/>
|
|
415
414
|
</>
|
|
416
415
|
);
|
package/src/hooks/margin.js
CHANGED
|
@@ -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 () =>
|
|
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
|
+
}
|
package/src/hooks/padding.js
CHANGED
|
@@ -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 () =>
|
|
214
|
+
return () => {
|
|
215
|
+
setIsActive( false );
|
|
216
|
+
clearTimer();
|
|
217
|
+
};
|
|
217
218
|
}, [ padding, forceShow ] );
|
|
218
219
|
|
|
219
220
|
if ( ! isActive && ! forceShow ) {
|
package/src/hooks/style.js
CHANGED
|
@@ -27,7 +27,11 @@ import {
|
|
|
27
27
|
TYPOGRAPHY_SUPPORT_KEY,
|
|
28
28
|
TYPOGRAPHY_SUPPORT_KEYS,
|
|
29
29
|
} from './typography';
|
|
30
|
-
import {
|
|
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
|
-
|
|
110
|
+
SPACING_SUPPORT_KEY,
|
|
103
111
|
],
|
|
104
112
|
};
|
|
105
113
|
|
package/src/hooks/test/style.js
CHANGED
|
@@ -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) *
|
|
45
|
+
'clamp(1.5rem, 1.5rem + ((1vw - 0.48rem) * 0.962), 2rem)',
|
|
46
46
|
textTransform: 'uppercase',
|
|
47
47
|
},
|
|
48
48
|
} );
|