@wordpress/block-editor 8.0.15 → 8.0.18
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/build/components/block-preview/auto.js +23 -5
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +88 -0
- package/build/components/colors-gradients/dropdown.js.map +1 -0
- package/build/components/colors-gradients/panel-color-gradient-settings.js +6 -5
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +5 -2
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/hooks/border-color.js +11 -5
- package/build/hooks/border-color.js.map +1 -1
- package/build/hooks/color.js +3 -3
- package/build/hooks/color.js.map +1 -1
- package/build/store/defaults.js +1 -0
- package/build/store/defaults.js.map +1 -1
- package/build-module/components/block-preview/auto.js +24 -5
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +75 -0
- package/build-module/components/colors-gradients/dropdown.js.map +1 -0
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +8 -7
- package/build-module/components/colors-gradients/panel-color-gradient-settings.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/link-control/link-preview.js +5 -2
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/hooks/border-color.js +11 -5
- package/build-module/hooks/border-color.js.map +1 -1
- package/build-module/hooks/color.js +3 -3
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/store/defaults.js +1 -0
- package/build-module/store/defaults.js.map +1 -1
- package/build-style/style-rtl.css +42 -0
- package/build-style/style.css +42 -0
- package/package.json +5 -5
- package/src/components/block-preview/auto.js +29 -1
- package/src/components/colors-gradients/dropdown.js +91 -0
- package/src/components/colors-gradients/panel-color-gradient-settings.js +23 -19
- package/src/components/colors-gradients/style.scss +49 -0
- package/src/components/index.js +1 -0
- package/src/components/link-control/link-preview.js +2 -1
- package/src/hooks/border-color.js +14 -6
- package/src/hooks/color.js +3 -3
- package/src/hooks/dimensions.scss +5 -0
- package/src/store/defaults.js +1 -0
- package/src/style.scss +1 -0
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { Disabled } from '@wordpress/components';
|
|
5
5
|
import { useResizeObserver, pure, useRefEffect } from '@wordpress/compose';
|
|
6
6
|
import { useSelect } from '@wordpress/data';
|
|
7
|
+
import { useMemo } from '@wordpress/element';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Internal dependencies
|
|
@@ -16,6 +17,8 @@ import { store } from '../../store';
|
|
|
16
17
|
// This is used to avoid rendering the block list if the sizes change.
|
|
17
18
|
let MemoizedBlockList;
|
|
18
19
|
|
|
20
|
+
const MAX_HEIGHT = 2000;
|
|
21
|
+
|
|
19
22
|
function AutoBlockPreview( { viewportWidth, __experimentalPadding } ) {
|
|
20
23
|
const [
|
|
21
24
|
containerResizeListener,
|
|
@@ -29,6 +32,21 @@ function AutoBlockPreview( { viewportWidth, __experimentalPadding } ) {
|
|
|
29
32
|
return select( store ).getSettings().styles;
|
|
30
33
|
}, [] );
|
|
31
34
|
|
|
35
|
+
// Avoid scrollbars for pattern previews.
|
|
36
|
+
const editorStyles = useMemo( () => {
|
|
37
|
+
if ( styles ) {
|
|
38
|
+
return [
|
|
39
|
+
...styles,
|
|
40
|
+
{
|
|
41
|
+
css: 'body{height:auto;overflow:hidden;}',
|
|
42
|
+
__unstableType: 'presets',
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return styles;
|
|
48
|
+
}, [ styles ] );
|
|
49
|
+
|
|
32
50
|
// Initialize on render instead of module top level, to avoid circular dependency issues.
|
|
33
51
|
MemoizedBlockList = MemoizedBlockList || pure( BlockList );
|
|
34
52
|
|
|
@@ -42,10 +60,14 @@ function AutoBlockPreview( { viewportWidth, __experimentalPadding } ) {
|
|
|
42
60
|
style={ {
|
|
43
61
|
transform: `scale(${ scale })`,
|
|
44
62
|
height: contentHeight * scale,
|
|
63
|
+
maxHeight:
|
|
64
|
+
contentHeight > MAX_HEIGHT
|
|
65
|
+
? MAX_HEIGHT * scale
|
|
66
|
+
: undefined,
|
|
45
67
|
} }
|
|
46
68
|
>
|
|
47
69
|
<Iframe
|
|
48
|
-
head={ <EditorStyles styles={
|
|
70
|
+
head={ <EditorStyles styles={ editorStyles } /> }
|
|
49
71
|
contentRef={ useRefEffect( ( bodyElement ) => {
|
|
50
72
|
const {
|
|
51
73
|
ownerDocument: { documentElement },
|
|
@@ -57,6 +79,9 @@ function AutoBlockPreview( { viewportWidth, __experimentalPadding } ) {
|
|
|
57
79
|
documentElement.style.width = '100%';
|
|
58
80
|
bodyElement.style.padding =
|
|
59
81
|
__experimentalPadding + 'px';
|
|
82
|
+
|
|
83
|
+
// necessary for contentResizeListener to work.
|
|
84
|
+
bodyElement.style.position = 'relative';
|
|
60
85
|
}, [] ) }
|
|
61
86
|
aria-hidden
|
|
62
87
|
tabIndex={ -1 }
|
|
@@ -65,6 +90,9 @@ function AutoBlockPreview( { viewportWidth, __experimentalPadding } ) {
|
|
|
65
90
|
width: viewportWidth,
|
|
66
91
|
height: contentHeight,
|
|
67
92
|
pointerEvents: 'none',
|
|
93
|
+
// This is a catch-all max-height for patterns.
|
|
94
|
+
// See: https://github.com/WordPress/gutenberg/pull/38175.
|
|
95
|
+
maxHeight: MAX_HEIGHT,
|
|
68
96
|
} }
|
|
69
97
|
>
|
|
70
98
|
{ contentResizeListener }
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import {
|
|
10
|
+
__experimentalItemGroup as ItemGroup,
|
|
11
|
+
__experimentalItem as Item,
|
|
12
|
+
__experimentalHStack as HStack,
|
|
13
|
+
FlexItem,
|
|
14
|
+
ColorIndicator,
|
|
15
|
+
Dropdown,
|
|
16
|
+
} from '@wordpress/components';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
import ColorGradientControl from './control';
|
|
22
|
+
|
|
23
|
+
export default function ColorGradientSettingsDropdown( {
|
|
24
|
+
colors,
|
|
25
|
+
gradients,
|
|
26
|
+
disableCustomColors,
|
|
27
|
+
disableCustomGradients,
|
|
28
|
+
__experimentalHasMultipleOrigins,
|
|
29
|
+
__experimentalIsRenderedInSidebar,
|
|
30
|
+
enableAlpha,
|
|
31
|
+
settings,
|
|
32
|
+
} ) {
|
|
33
|
+
let dropdownPosition;
|
|
34
|
+
if ( __experimentalIsRenderedInSidebar ) {
|
|
35
|
+
dropdownPosition = 'bottom left';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<ItemGroup
|
|
40
|
+
isBordered
|
|
41
|
+
isSeparated
|
|
42
|
+
className="block-editor-panel-color-gradient-settings__item-group"
|
|
43
|
+
>
|
|
44
|
+
{ settings.map( ( setting, index ) => (
|
|
45
|
+
<Dropdown
|
|
46
|
+
key={ index }
|
|
47
|
+
position={ dropdownPosition }
|
|
48
|
+
className="block-editor-panel-color-gradient-settings__dropdown"
|
|
49
|
+
contentClassName="block-editor-panel-color-gradient-settings__dropdown-content"
|
|
50
|
+
renderToggle={ ( { isOpen, onToggle } ) => {
|
|
51
|
+
return (
|
|
52
|
+
<Item
|
|
53
|
+
onClick={ onToggle }
|
|
54
|
+
className={ classnames(
|
|
55
|
+
'block-editor-panel-color-gradient-settings__item',
|
|
56
|
+
{ 'is-open': isOpen }
|
|
57
|
+
) }
|
|
58
|
+
>
|
|
59
|
+
<HStack justify="flex-start">
|
|
60
|
+
<ColorIndicator
|
|
61
|
+
className="block-editor-panel-color-gradient-settings__color-indicator"
|
|
62
|
+
colorValue={
|
|
63
|
+
setting.gradientValue ??
|
|
64
|
+
setting.colorValue
|
|
65
|
+
}
|
|
66
|
+
/>
|
|
67
|
+
<FlexItem>{ setting.label }</FlexItem>
|
|
68
|
+
</HStack>
|
|
69
|
+
</Item>
|
|
70
|
+
);
|
|
71
|
+
} }
|
|
72
|
+
renderContent={ () => (
|
|
73
|
+
<ColorGradientControl
|
|
74
|
+
showTitle={ false }
|
|
75
|
+
{ ...{
|
|
76
|
+
colors,
|
|
77
|
+
gradients,
|
|
78
|
+
disableCustomColors,
|
|
79
|
+
disableCustomGradients,
|
|
80
|
+
__experimentalHasMultipleOrigins,
|
|
81
|
+
__experimentalIsRenderedInSidebar,
|
|
82
|
+
enableAlpha,
|
|
83
|
+
...setting,
|
|
84
|
+
} }
|
|
85
|
+
/>
|
|
86
|
+
) }
|
|
87
|
+
/>
|
|
88
|
+
) ) }
|
|
89
|
+
</ItemGroup>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
@@ -7,13 +7,17 @@ import { every, isEmpty } from 'lodash';
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
__experimentalSpacer as Spacer,
|
|
12
|
+
ColorIndicator,
|
|
13
|
+
PanelBody,
|
|
14
|
+
} from '@wordpress/components';
|
|
11
15
|
import { sprintf, __ } from '@wordpress/i18n';
|
|
12
16
|
|
|
13
17
|
/**
|
|
14
18
|
* Internal dependencies
|
|
15
19
|
*/
|
|
16
|
-
import
|
|
20
|
+
import ColorGradientSettingsDropdown from './dropdown';
|
|
17
21
|
import { getColorObjectByColorValue } from '../colors';
|
|
18
22
|
import { __experimentalGetGradientObjectByGradientValue } from '../gradients';
|
|
19
23
|
import useSetting from '../use-setting';
|
|
@@ -136,23 +140,23 @@ export const PanelColorGradientSettingsInner = ( {
|
|
|
136
140
|
title={ showTitle ? titleElement : undefined }
|
|
137
141
|
{ ...props }
|
|
138
142
|
>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
143
|
+
<ColorGradientSettingsDropdown
|
|
144
|
+
settings={ settings }
|
|
145
|
+
{ ...{
|
|
146
|
+
colors,
|
|
147
|
+
gradients,
|
|
148
|
+
disableCustomColors,
|
|
149
|
+
disableCustomGradients,
|
|
150
|
+
__experimentalHasMultipleOrigins,
|
|
151
|
+
__experimentalIsRenderedInSidebar,
|
|
152
|
+
enableAlpha,
|
|
153
|
+
} }
|
|
154
|
+
/>
|
|
155
|
+
{ !! children && (
|
|
156
|
+
<>
|
|
157
|
+
<Spacer marginY={ 4 } /> { children }
|
|
158
|
+
</>
|
|
159
|
+
) }
|
|
156
160
|
</PanelBody>
|
|
157
161
|
);
|
|
158
162
|
};
|
|
@@ -37,4 +37,53 @@
|
|
|
37
37
|
.block-editor-block-inspector & .components-base-control {
|
|
38
38
|
margin-bottom: inherit;
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
.block-editor-panel-color-gradient-settings__dropdown {
|
|
42
|
+
display: block;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.block-editor-panel-color-gradient-settings__dropdown {
|
|
47
|
+
width: 100%;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.block-editor-panel-color-gradient-settings__dropdown-content .components-popover__content {
|
|
51
|
+
& > div {
|
|
52
|
+
width: $sidebar-width;
|
|
53
|
+
}
|
|
40
54
|
}
|
|
55
|
+
|
|
56
|
+
@include break-medium() {
|
|
57
|
+
.block-editor-panel-color-gradient-settings__dropdown-content {
|
|
58
|
+
.components-popover__content {
|
|
59
|
+
margin-right: #{ math.div($sidebar-width, 2) + $grid-unit-20 } !important;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&.is-from-top .components-popover__content {
|
|
63
|
+
margin-top: #{ -($grid-unit-60 + $grid-unit-15) } !important;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&.is-from-bottom .components-popover__content {
|
|
67
|
+
margin-bottom: #{ -($grid-unit-60 + $grid-unit-15) } !important;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.block-editor-panel-color-gradient-settings__dropdown:last-child > div {
|
|
73
|
+
border-bottom-width: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.block-editor-panel-color-gradient-settings__item {
|
|
77
|
+
padding-top: $grid-unit-15 !important;
|
|
78
|
+
padding-bottom: $grid-unit-15 !important;
|
|
79
|
+
.block-editor-panel-color-gradient-settings__color-indicator {
|
|
80
|
+
// Show a diagonal line (crossed out) for empty swatches.
|
|
81
|
+
background: linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&.is-open {
|
|
85
|
+
background: $gray-100;
|
|
86
|
+
color: var(--wp-admin-theme-color);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
package/src/components/index.js
CHANGED
|
@@ -48,6 +48,7 @@ export { default as __experimentalLetterSpacingControl } from './letter-spacing-
|
|
|
48
48
|
export { default as __experimentalTextDecorationControl } from './text-decoration-control';
|
|
49
49
|
export { default as __experimentalTextTransformControl } from './text-transform-control';
|
|
50
50
|
export { default as __experimentalColorGradientControl } from './colors-gradients/control';
|
|
51
|
+
export { default as __experimentalColorGradientSettingsDropdown } from './colors-gradients/dropdown';
|
|
51
52
|
export { default as __experimentalPanelColorGradientSettings } from './colors-gradients/panel-color-gradient-settings';
|
|
52
53
|
export {
|
|
53
54
|
default as __experimentalImageEditor,
|
|
@@ -44,7 +44,8 @@ export default function LinkPreview( {
|
|
|
44
44
|
|
|
45
45
|
const displayTitle = richData?.title || value?.title || displayURL;
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
// url can be undefined if the href attribute is unset
|
|
48
|
+
const isEmptyURL = ! value?.url?.length;
|
|
48
49
|
|
|
49
50
|
let icon;
|
|
50
51
|
|
|
@@ -14,7 +14,7 @@ import { useState } from '@wordpress/element';
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
|
-
import
|
|
17
|
+
import ColorGradientSettingsDropdown from '../components/colors-gradients/dropdown';
|
|
18
18
|
import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
|
|
19
19
|
import {
|
|
20
20
|
getColorClassName,
|
|
@@ -85,14 +85,22 @@ export function BorderColorEdit( props ) {
|
|
|
85
85
|
} );
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
const settings = [
|
|
89
|
+
{
|
|
90
|
+
label: __( 'Color' ),
|
|
91
|
+
onColorChange: onChangeColor,
|
|
92
|
+
colorValue,
|
|
93
|
+
clearable: false,
|
|
94
|
+
},
|
|
95
|
+
];
|
|
88
96
|
return (
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
clearable={ false }
|
|
97
|
+
<ColorGradientSettingsDropdown
|
|
98
|
+
settings={ settings }
|
|
99
|
+
disableCustomColors
|
|
100
|
+
disableCustomGradients
|
|
94
101
|
__experimentalHasMultipleOrigins
|
|
95
102
|
__experimentalIsRenderedInSidebar
|
|
103
|
+
enableAlpha
|
|
96
104
|
{ ...colorGradientSettings }
|
|
97
105
|
/>
|
|
98
106
|
);
|
package/src/hooks/color.js
CHANGED
|
@@ -382,7 +382,7 @@ export function ColorEdit( props ) {
|
|
|
382
382
|
...( hasTextColor
|
|
383
383
|
? [
|
|
384
384
|
{
|
|
385
|
-
label: __( 'Text
|
|
385
|
+
label: __( 'Text' ),
|
|
386
386
|
onColorChange: onChangeColor( 'text' ),
|
|
387
387
|
colorValue: getColorObjectByAttributeValues(
|
|
388
388
|
allSolids,
|
|
@@ -395,7 +395,7 @@ export function ColorEdit( props ) {
|
|
|
395
395
|
...( hasBackgroundColor || hasGradientColor
|
|
396
396
|
? [
|
|
397
397
|
{
|
|
398
|
-
label: __( 'Background
|
|
398
|
+
label: __( 'Background' ),
|
|
399
399
|
onColorChange: hasBackgroundColor
|
|
400
400
|
? onChangeColor( 'background' )
|
|
401
401
|
: undefined,
|
|
@@ -414,7 +414,7 @@ export function ColorEdit( props ) {
|
|
|
414
414
|
...( hasLinkColor
|
|
415
415
|
? [
|
|
416
416
|
{
|
|
417
|
-
label: __( 'Link
|
|
417
|
+
label: __( 'Link' ),
|
|
418
418
|
onColorChange: onChangeLinkColor,
|
|
419
419
|
colorValue: getLinkColorFromAttributeValue(
|
|
420
420
|
allSolids,
|
package/src/store/defaults.js
CHANGED
|
@@ -156,6 +156,7 @@ export const SETTINGS_DEFAULTS = {
|
|
|
156
156
|
__experimentalBlockPatterns: [],
|
|
157
157
|
__experimentalBlockPatternCategories: [],
|
|
158
158
|
__experimentalSpotlightEntityBlocks: [],
|
|
159
|
+
__experimentalGenerateAnchors: false,
|
|
159
160
|
__unstableGalleryWithImageBlocks: false,
|
|
160
161
|
|
|
161
162
|
// gradients setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
|
package/src/style.scss
CHANGED