@wordpress/block-editor 9.4.0 → 9.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 +2 -0
- package/README.md +1 -8
- package/build/components/block-list/block-invalid-warning.native.js +54 -6
- package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build/components/block-list/block.js +2 -2
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +2 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +4 -3
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/layout.js +20 -5
- package/build/components/block-list/layout.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +5 -2
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-lock/modal.js +35 -5
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +5 -17
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-popover/inbetween.js +1 -1
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +1 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-settings-menu/block-mode-toggle.js +1 -1
- package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/preview.native.js +3 -1
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-switcher/index.js +7 -1
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-title/index.js +8 -2
- package/build/components/block-title/index.js.map +1 -1
- package/build/components/block-title/use-block-display-title.js +12 -5
- package/build/components/block-title/use-block-display-title.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/border-radius-control/index.js +2 -0
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/colors/with-colors.js +1 -1
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +45 -39
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/date-format-picker/index.js +1 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/iframe/index.js +19 -6
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/link-control/index.js +1 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +15 -7
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +1 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/media-placeholder/index.js +13 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +3 -6
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/url-popover/index.js +2 -1
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +34 -2
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +3 -47
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +1 -3
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/color.js +2 -4
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/index.js +8 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +41 -14
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/utils.js +5 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +40 -36
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +10 -35
- package/build/layouts/flow.js.map +1 -1
- package/build/layouts/utils.js +35 -3
- package/build/layouts/utils.js.map +1 -1
- package/build/store/actions.js +15 -18
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +0 -4
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +5 -3
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +3 -3
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-list/block-invalid-warning.native.js +50 -6
- package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build-module/components/block-list/block.js +2 -2
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -1
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +3 -1
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/layout.js +19 -4
- package/build-module/components/block-list/layout.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +5 -2
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-lock/modal.js +37 -6
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +6 -18
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +1 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +1 -1
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-mode-toggle.js +1 -1
- package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js +3 -2
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-switcher/index.js +7 -1
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-title/index.js +8 -2
- package/build-module/components/block-title/index.js.map +1 -1
- package/build-module/components/block-title/use-block-display-title.js +12 -5
- package/build-module/components/block-title/use-block-display-title.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +2 -0
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/colors/with-colors.js +2 -2
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +46 -40
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +1 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/iframe/index.js +19 -6
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +16 -8
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +1 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +13 -2
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +4 -7
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/url-popover/index.js +2 -1
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +35 -3
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +3 -45
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +1 -3
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/color.js +2 -3
- package/build-module/hooks/color.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/layout.js +42 -15
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/utils.js +5 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +41 -33
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +11 -36
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/layouts/utils.js +33 -3
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/store/actions.js +9 -10
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +0 -4
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +5 -2
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +4 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +36 -10
- package/build-style/style.css +36 -10
- package/package.json +28 -28
- package/src/components/block-list/block-invalid-warning.native.js +42 -7
- package/src/components/block-list/block.js +2 -2
- package/src/components/block-list/block.native.js +1 -0
- package/src/components/block-list/index.native.js +1 -1
- package/src/components/block-list/layout.js +15 -3
- package/src/components/block-list/style.scss +1 -1
- package/src/components/block-list/use-block-props/use-block-class-names.js +5 -1
- package/src/components/block-lock/modal.js +42 -4
- package/src/components/block-lock/style.scss +10 -0
- package/src/components/block-pattern-setup/index.js +3 -15
- package/src/components/block-pattern-setup/style.scss +4 -2
- package/src/components/block-popover/inbetween.js +1 -1
- package/src/components/block-popover/index.js +1 -1
- package/src/components/block-settings-menu/block-mode-toggle.js +1 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/src/components/block-styles/preview.native.js +3 -2
- package/src/components/block-switcher/index.js +7 -1
- package/src/components/block-title/index.js +3 -2
- package/src/components/block-title/use-block-display-title.js +11 -5
- package/src/components/block-tools/block-contextual-toolbar.js +3 -1
- package/src/components/border-radius-control/index.js +2 -0
- package/src/components/colors/with-colors.js +2 -2
- package/src/components/colors-gradients/control.js +77 -65
- package/src/components/colors-gradients/style.scss +4 -0
- package/src/components/colors-gradients/test/control.js +16 -23
- package/src/components/date-format-picker/index.js +1 -0
- package/src/components/iframe/index.js +25 -6
- package/src/components/inserter/style.scss +1 -1
- package/src/components/link-control/index.js +1 -0
- package/src/components/link-control/test/index.js +6 -4
- package/src/components/list-view/block-select-button.js +29 -14
- package/src/components/list-view/drop-indicator.js +1 -1
- package/src/components/list-view/style.scss +18 -4
- package/src/components/media-placeholder/index.js +19 -0
- package/src/components/media-replace-flow/index.js +3 -6
- package/src/components/media-replace-flow/test/index.js +14 -4
- package/src/components/url-popover/index.js +1 -0
- package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -0
- package/src/components/writing-flow/use-arrow-nav.js +32 -1
- package/src/components/writing-flow/use-multi-selection.js +1 -48
- package/src/components/writing-flow/use-selection-observer.js +2 -3
- package/src/hooks/color.js +10 -3
- package/src/hooks/index.js +1 -0
- package/src/hooks/layout.js +46 -20
- package/src/hooks/utils.js +7 -3
- package/src/index.js +1 -0
- package/src/layouts/flex.js +47 -41
- package/src/layouts/flow.js +14 -35
- package/src/layouts/test/flex.js +21 -0
- package/src/layouts/test/flow.js +21 -0
- package/src/layouts/test/utils.js +138 -0
- package/src/layouts/utils.js +44 -3
- package/src/store/actions.js +10 -11
- package/src/store/index.js +0 -4
- package/src/store/reducer.js +3 -2
- package/src/store/selectors.js +3 -4
- package/tsconfig.json +2 -1
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from '@wordpress/components';
|
|
12
12
|
|
|
13
13
|
import { useState } from '@wordpress/element';
|
|
14
|
-
import { useInstanceId
|
|
14
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
15
15
|
import { __ } from '@wordpress/i18n';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -28,7 +28,6 @@ const SetupContent = ( {
|
|
|
28
28
|
activeSlide,
|
|
29
29
|
patterns,
|
|
30
30
|
onBlockPatternSelect,
|
|
31
|
-
height,
|
|
32
31
|
} ) => {
|
|
33
32
|
const composite = useCompositeState();
|
|
34
33
|
const containerClass = 'block-editor-block-pattern-setup__container';
|
|
@@ -39,10 +38,7 @@ const SetupContent = ( {
|
|
|
39
38
|
[ activeSlide + 1, 'next-slide' ],
|
|
40
39
|
] );
|
|
41
40
|
return (
|
|
42
|
-
<div
|
|
43
|
-
className="block-editor-block-pattern-setup__carousel"
|
|
44
|
-
style={ { height } }
|
|
45
|
-
>
|
|
41
|
+
<div className="block-editor-block-pattern-setup__carousel">
|
|
46
42
|
<div className={ containerClass }>
|
|
47
43
|
<ul className="carousel-container">
|
|
48
44
|
{ patterns.map( ( pattern, index ) => (
|
|
@@ -50,7 +46,6 @@ const SetupContent = ( {
|
|
|
50
46
|
className={ slideClass.get( index ) || '' }
|
|
51
47
|
key={ pattern.name }
|
|
52
48
|
pattern={ pattern }
|
|
53
|
-
minHeight={ height }
|
|
54
49
|
/>
|
|
55
50
|
) ) }
|
|
56
51
|
</ul>
|
|
@@ -59,10 +54,7 @@ const SetupContent = ( {
|
|
|
59
54
|
);
|
|
60
55
|
}
|
|
61
56
|
return (
|
|
62
|
-
<div
|
|
63
|
-
style={ { height } }
|
|
64
|
-
className="block-editor-block-pattern-setup__grid"
|
|
65
|
-
>
|
|
57
|
+
<div className="block-editor-block-pattern-setup__grid">
|
|
66
58
|
<Composite
|
|
67
59
|
{ ...composite }
|
|
68
60
|
role="listbox"
|
|
@@ -151,8 +143,6 @@ const BlockPatternSetup = ( {
|
|
|
151
143
|
const [ activeSlide, setActiveSlide ] = useState( 0 );
|
|
152
144
|
const { replaceBlock } = useDispatch( blockEditorStore );
|
|
153
145
|
const patterns = usePatternsSetup( clientId, blockName, filterPatternsFn );
|
|
154
|
-
const [ contentResizeListener, { height: contentHeight } ] =
|
|
155
|
-
useResizeObserver();
|
|
156
146
|
|
|
157
147
|
if ( ! patterns?.length ) {
|
|
158
148
|
return null;
|
|
@@ -166,7 +156,6 @@ const BlockPatternSetup = ( {
|
|
|
166
156
|
onBlockPatternSelect || onBlockPatternSelectDefault;
|
|
167
157
|
return (
|
|
168
158
|
<>
|
|
169
|
-
{ contentResizeListener }
|
|
170
159
|
<div
|
|
171
160
|
className={ `block-editor-block-pattern-setup view-mode-${ viewMode }` }
|
|
172
161
|
>
|
|
@@ -175,7 +164,6 @@ const BlockPatternSetup = ( {
|
|
|
175
164
|
activeSlide={ activeSlide }
|
|
176
165
|
patterns={ patterns }
|
|
177
166
|
onBlockPatternSelect={ onPatternSelectCallback }
|
|
178
|
-
height={ contentHeight - 2 * 60 }
|
|
179
167
|
/>
|
|
180
168
|
<SetupToolbar
|
|
181
169
|
viewMode={ viewMode }
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
display: block;
|
|
18
18
|
width: 100%;
|
|
19
19
|
padding: $grid-unit-40;
|
|
20
|
+
padding-bottom: 0;
|
|
21
|
+
padding-top: 0;
|
|
20
22
|
column-count: 2;
|
|
21
23
|
|
|
22
24
|
@include break-huge() {
|
|
@@ -53,8 +55,9 @@
|
|
|
53
55
|
text-align: left;
|
|
54
56
|
margin: 0;
|
|
55
57
|
color: $gray-900;
|
|
58
|
+
position: absolute;
|
|
59
|
+
bottom: 0;
|
|
56
60
|
// Block UI appearance.
|
|
57
|
-
border-radius: $radius-block-ui $radius-block-ui 0 0;
|
|
58
61
|
background-color: $white;
|
|
59
62
|
display: flex;
|
|
60
63
|
flex-direction: row;
|
|
@@ -129,5 +132,4 @@
|
|
|
129
132
|
.block-editor-block-pattern-setup__carousel,
|
|
130
133
|
.block-editor-block-pattern-setup__grid {
|
|
131
134
|
width: 100%;
|
|
132
|
-
overflow-y: auto;
|
|
133
135
|
}
|
|
@@ -172,7 +172,7 @@ function BlockPopoverInbetween( {
|
|
|
172
172
|
getAnchorRect={ getAnchorRect }
|
|
173
173
|
focusOnMount={ false }
|
|
174
174
|
// Render in the old slot if needed for backward compatibility,
|
|
175
|
-
// otherwise render in place (not in the
|
|
175
|
+
// otherwise render in place (not in the default popover slot).
|
|
176
176
|
__unstableSlotName={ __unstablePopoverSlot || null }
|
|
177
177
|
// Forces a remount of the popover when its position changes
|
|
178
178
|
// This makes sure the popover doesn't animate from its previous position.
|
|
@@ -57,7 +57,7 @@ export default function BlockPopover( {
|
|
|
57
57
|
focusOnMount={ false }
|
|
58
58
|
anchorRef={ anchorRef }
|
|
59
59
|
// Render in the old slot if needed for backward compatibility,
|
|
60
|
-
// otherwise render in place (not in the
|
|
60
|
+
// otherwise render in place (not in the default popover slot).
|
|
61
61
|
__unstableSlotName={ __unstablePopoverSlot || null }
|
|
62
62
|
// Observe movement for block animations (especially horizontal).
|
|
63
63
|
__unstableObserveElement={ selectedElement }
|
|
@@ -125,7 +125,10 @@ export function BlockSettingsDropdown( {
|
|
|
125
125
|
[ __experimentalSelectBlock ]
|
|
126
126
|
);
|
|
127
127
|
|
|
128
|
-
const blockTitle = useBlockDisplayTitle(
|
|
128
|
+
const blockTitle = useBlockDisplayTitle( {
|
|
129
|
+
clientId: firstBlockClientId,
|
|
130
|
+
maximumLength: 25,
|
|
131
|
+
} );
|
|
129
132
|
|
|
130
133
|
const updateSelectionAfterRemove = useCallback(
|
|
131
134
|
__experimentalSelectBlock
|
|
@@ -8,8 +8,9 @@ import {
|
|
|
8
8
|
Dimensions,
|
|
9
9
|
Animated,
|
|
10
10
|
Easing,
|
|
11
|
-
Image,
|
|
12
11
|
} from 'react-native';
|
|
12
|
+
import FastImage from 'react-native-fast-image';
|
|
13
|
+
|
|
13
14
|
/**
|
|
14
15
|
* WordPress dependencies
|
|
15
16
|
*/
|
|
@@ -90,7 +91,7 @@ function StylePreview( { onPress, isActive, style, url } ) {
|
|
|
90
91
|
<View style={ styles.imageWrapper }>
|
|
91
92
|
{ isActive &&
|
|
92
93
|
getOutline( [ styles.outline, innerOutlineStyle ] ) }
|
|
93
|
-
<
|
|
94
|
+
<FastImage
|
|
94
95
|
style={ [ styles.image, styles[ name ] ] }
|
|
95
96
|
source={ { uri: url } }
|
|
96
97
|
/>
|
|
@@ -98,8 +98,14 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
98
98
|
// Pattern transformation through the `Patterns` API.
|
|
99
99
|
const onPatternTransform = ( transformedBlocks ) =>
|
|
100
100
|
replaceBlocks( clientIds, transformedBlocks );
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The `isTemplate` check is a stopgap solution here.
|
|
104
|
+
* Ideally, the Transforms API should handle this
|
|
105
|
+
* by allowing to exclude blocks from wildcard transformations.
|
|
106
|
+
*/
|
|
101
107
|
const hasPossibleBlockTransformations =
|
|
102
|
-
!! possibleBlockTransformations.length && canRemove;
|
|
108
|
+
!! possibleBlockTransformations.length && canRemove && ! isTemplate;
|
|
103
109
|
const hasPatternTransformation = !! patterns?.length && canRemove;
|
|
104
110
|
if ( ! hasBlockStyles && ! hasPossibleBlockTransformations ) {
|
|
105
111
|
return (
|
|
@@ -17,9 +17,10 @@ import useBlockDisplayTitle from './use-block-display-title';
|
|
|
17
17
|
* @param {Object} props
|
|
18
18
|
* @param {string} props.clientId Client ID of block.
|
|
19
19
|
* @param {number|undefined} props.maximumLength The maximum length that the block title string may be before truncated.
|
|
20
|
+
* @param {string|undefined} props.context The context to pass to `getBlockLabel`.
|
|
20
21
|
*
|
|
21
22
|
* @return {JSX.Element} Block title.
|
|
22
23
|
*/
|
|
23
|
-
export default function BlockTitle( { clientId, maximumLength } ) {
|
|
24
|
-
return useBlockDisplayTitle( clientId, maximumLength );
|
|
24
|
+
export default function BlockTitle( { clientId, maximumLength, context } ) {
|
|
25
|
+
return useBlockDisplayTitle( { clientId, maximumLength, context } );
|
|
25
26
|
}
|
|
@@ -21,14 +21,20 @@ import { store as blockEditorStore } from '../../store';
|
|
|
21
21
|
* @example
|
|
22
22
|
*
|
|
23
23
|
* ```js
|
|
24
|
-
* useBlockDisplayTitle( 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1', 17 );
|
|
24
|
+
* useBlockDisplayTitle( { clientId: 'afd1cb17-2c08-4e7a-91be-007ba7ddc3a1', maximumLength: 17 } );
|
|
25
25
|
* ```
|
|
26
26
|
*
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {
|
|
27
|
+
* @param {Object} props
|
|
28
|
+
* @param {string} props.clientId Client ID of block.
|
|
29
|
+
* @param {number|undefined} props.maximumLength The maximum length that the block title string may be before truncated.
|
|
30
|
+
* @param {string|undefined} props.context The context to pass to `getBlockLabel`.
|
|
29
31
|
* @return {?string} Block title.
|
|
30
32
|
*/
|
|
31
|
-
export default function useBlockDisplayTitle(
|
|
33
|
+
export default function useBlockDisplayTitle( {
|
|
34
|
+
clientId,
|
|
35
|
+
maximumLength,
|
|
36
|
+
context,
|
|
37
|
+
} ) {
|
|
32
38
|
const { attributes, name, reusableBlockTitle } = useSelect(
|
|
33
39
|
( select ) => {
|
|
34
40
|
if ( ! clientId ) {
|
|
@@ -63,7 +69,7 @@ export default function useBlockDisplayTitle( clientId, maximumLength ) {
|
|
|
63
69
|
}
|
|
64
70
|
const blockType = getBlockType( name );
|
|
65
71
|
const blockLabel = blockType
|
|
66
|
-
? getBlockLabel( blockType, attributes )
|
|
72
|
+
? getBlockLabel( blockType, attributes, context )
|
|
67
73
|
: null;
|
|
68
74
|
|
|
69
75
|
const label = reusableBlockTitle || blockLabel;
|
|
@@ -36,11 +36,13 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
|
|
|
36
36
|
getBlockType( getBlockName( selectedBlockClientId ) ),
|
|
37
37
|
hasParents: parents.length,
|
|
38
38
|
showParentSelector:
|
|
39
|
+
parentBlockType &&
|
|
39
40
|
hasBlockSupport(
|
|
40
41
|
parentBlockType,
|
|
41
42
|
'__experimentalParentSelector',
|
|
42
43
|
true
|
|
43
|
-
) &&
|
|
44
|
+
) &&
|
|
45
|
+
selectedBlockClientIds.length <= 1,
|
|
44
46
|
};
|
|
45
47
|
},
|
|
46
48
|
[]
|
|
@@ -82,6 +82,8 @@ export default function BorderRadiusControl( { onChange, values } ) {
|
|
|
82
82
|
units={ units }
|
|
83
83
|
/>
|
|
84
84
|
<RangeControl
|
|
85
|
+
label={ __( 'Border radius' ) }
|
|
86
|
+
hideLabelFromVision
|
|
85
87
|
className="components-border-radius-control__range-control"
|
|
86
88
|
value={ allValue ?? '' }
|
|
87
89
|
min={ MIN_BORDER_RADIUS_VALUE }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { kebabCase, reduce, upperFirst } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -78,7 +78,7 @@ function createColorHOC( colorTypes, withColorPalette ) {
|
|
|
78
78
|
( colorObject, colorType ) => {
|
|
79
79
|
return {
|
|
80
80
|
...colorObject,
|
|
81
|
-
...(
|
|
81
|
+
...( typeof colorType === 'string'
|
|
82
82
|
? { [ colorType ]: kebabCase( colorType ) }
|
|
83
83
|
: colorType ),
|
|
84
84
|
};
|
|
@@ -7,16 +7,13 @@ import { every, isEmpty } from 'lodash';
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { useState } from '@wordpress/element';
|
|
11
10
|
import {
|
|
12
11
|
BaseControl,
|
|
13
12
|
__experimentalVStack as VStack,
|
|
14
|
-
|
|
15
|
-
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
13
|
+
TabPanel,
|
|
16
14
|
ColorPalette,
|
|
17
15
|
GradientPicker,
|
|
18
16
|
} from '@wordpress/components';
|
|
19
|
-
import { __ } from '@wordpress/i18n';
|
|
20
17
|
|
|
21
18
|
/**
|
|
22
19
|
* Internal dependencies
|
|
@@ -30,6 +27,19 @@ const colorsAndGradientKeys = [
|
|
|
30
27
|
'disableCustomGradients',
|
|
31
28
|
];
|
|
32
29
|
|
|
30
|
+
const TAB_COLOR = {
|
|
31
|
+
name: 'color',
|
|
32
|
+
title: 'Solid color',
|
|
33
|
+
value: 'color',
|
|
34
|
+
};
|
|
35
|
+
const TAB_GRADIENT = {
|
|
36
|
+
name: 'gradient',
|
|
37
|
+
title: 'Gradient',
|
|
38
|
+
value: 'gradient',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const TABS_SETTINGS = [ TAB_COLOR, TAB_GRADIENT ];
|
|
42
|
+
|
|
33
43
|
function ColorGradientControlInner( {
|
|
34
44
|
colors,
|
|
35
45
|
gradients,
|
|
@@ -52,13 +62,57 @@ function ColorGradientControlInner( {
|
|
|
52
62
|
const canChooseAGradient =
|
|
53
63
|
onGradientChange &&
|
|
54
64
|
( ! isEmpty( gradients ) || ! disableCustomGradients );
|
|
55
|
-
const [ currentTab, setCurrentTab ] = useState(
|
|
56
|
-
gradientValue ? 'gradient' : !! canChooseAColor && 'color'
|
|
57
|
-
);
|
|
58
65
|
|
|
59
66
|
if ( ! canChooseAColor && ! canChooseAGradient ) {
|
|
60
67
|
return null;
|
|
61
68
|
}
|
|
69
|
+
|
|
70
|
+
const tabPanels = {
|
|
71
|
+
[ TAB_COLOR.value ]: (
|
|
72
|
+
<ColorPalette
|
|
73
|
+
value={ colorValue }
|
|
74
|
+
onChange={
|
|
75
|
+
canChooseAGradient
|
|
76
|
+
? ( newColor ) => {
|
|
77
|
+
onColorChange( newColor );
|
|
78
|
+
onGradientChange();
|
|
79
|
+
}
|
|
80
|
+
: onColorChange
|
|
81
|
+
}
|
|
82
|
+
{ ...{ colors, disableCustomColors } }
|
|
83
|
+
__experimentalHasMultipleOrigins={
|
|
84
|
+
__experimentalHasMultipleOrigins
|
|
85
|
+
}
|
|
86
|
+
__experimentalIsRenderedInSidebar={
|
|
87
|
+
__experimentalIsRenderedInSidebar
|
|
88
|
+
}
|
|
89
|
+
clearable={ clearable }
|
|
90
|
+
enableAlpha={ enableAlpha }
|
|
91
|
+
/>
|
|
92
|
+
),
|
|
93
|
+
[ TAB_GRADIENT.value ]: (
|
|
94
|
+
<GradientPicker
|
|
95
|
+
value={ gradientValue }
|
|
96
|
+
onChange={
|
|
97
|
+
canChooseAColor
|
|
98
|
+
? ( newGradient ) => {
|
|
99
|
+
onGradientChange( newGradient );
|
|
100
|
+
onColorChange();
|
|
101
|
+
}
|
|
102
|
+
: onGradientChange
|
|
103
|
+
}
|
|
104
|
+
{ ...{ gradients, disableCustomGradients } }
|
|
105
|
+
__experimentalHasMultipleOrigins={
|
|
106
|
+
__experimentalHasMultipleOrigins
|
|
107
|
+
}
|
|
108
|
+
__experimentalIsRenderedInSidebar={
|
|
109
|
+
__experimentalIsRenderedInSidebar
|
|
110
|
+
}
|
|
111
|
+
clearable={ clearable }
|
|
112
|
+
/>
|
|
113
|
+
),
|
|
114
|
+
};
|
|
115
|
+
|
|
62
116
|
return (
|
|
63
117
|
<BaseControl
|
|
64
118
|
className={ classnames(
|
|
@@ -78,66 +132,24 @@ function ColorGradientControlInner( {
|
|
|
78
132
|
</legend>
|
|
79
133
|
) }
|
|
80
134
|
{ canChooseAColor && canChooseAGradient && (
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
<ToggleGroupControlOption
|
|
89
|
-
value="color"
|
|
90
|
-
label={ __( 'Solid' ) }
|
|
91
|
-
/>
|
|
92
|
-
<ToggleGroupControlOption
|
|
93
|
-
value="gradient"
|
|
94
|
-
label={ __( 'Gradient' ) }
|
|
95
|
-
/>
|
|
96
|
-
</ToggleGroupControl>
|
|
97
|
-
) }
|
|
98
|
-
{ ( currentTab === 'color' || ! canChooseAGradient ) && (
|
|
99
|
-
<ColorPalette
|
|
100
|
-
value={ colorValue }
|
|
101
|
-
onChange={
|
|
102
|
-
canChooseAGradient
|
|
103
|
-
? ( newColor ) => {
|
|
104
|
-
onColorChange( newColor );
|
|
105
|
-
onGradientChange();
|
|
106
|
-
}
|
|
107
|
-
: onColorChange
|
|
135
|
+
<TabPanel
|
|
136
|
+
className="block-editor-color-gradient-control__tabs"
|
|
137
|
+
tabs={ TABS_SETTINGS }
|
|
138
|
+
initialTabName={
|
|
139
|
+
gradientValue
|
|
140
|
+
? TAB_GRADIENT.value
|
|
141
|
+
: !! canChooseAColor && TAB_COLOR.value
|
|
108
142
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
clearable={ clearable }
|
|
117
|
-
enableAlpha={ enableAlpha }
|
|
118
|
-
/>
|
|
119
|
-
) }
|
|
120
|
-
{ ( currentTab === 'gradient' || ! canChooseAColor ) && (
|
|
121
|
-
<GradientPicker
|
|
122
|
-
value={ gradientValue }
|
|
123
|
-
onChange={
|
|
124
|
-
canChooseAColor
|
|
125
|
-
? ( newGradient ) => {
|
|
126
|
-
onGradientChange( newGradient );
|
|
127
|
-
onColorChange();
|
|
128
|
-
}
|
|
129
|
-
: onGradientChange
|
|
130
|
-
}
|
|
131
|
-
{ ...{ gradients, disableCustomGradients } }
|
|
132
|
-
__experimentalHasMultipleOrigins={
|
|
133
|
-
__experimentalHasMultipleOrigins
|
|
134
|
-
}
|
|
135
|
-
__experimentalIsRenderedInSidebar={
|
|
136
|
-
__experimentalIsRenderedInSidebar
|
|
137
|
-
}
|
|
138
|
-
clearable={ clearable }
|
|
139
|
-
/>
|
|
143
|
+
>
|
|
144
|
+
{ ( tab ) => (
|
|
145
|
+
<div className="block-editor-color-gradient-control__tab-panel">
|
|
146
|
+
{ tabPanels[ tab.value ] }
|
|
147
|
+
</div>
|
|
148
|
+
) }
|
|
149
|
+
</TabPanel>
|
|
140
150
|
) }
|
|
151
|
+
{ ! canChooseAGradient && tabPanels[ TAB_COLOR.value ] }
|
|
152
|
+
{ ! canChooseAColor && tabPanels[ TAB_GRADIENT.value ] }
|
|
141
153
|
</VStack>
|
|
142
154
|
</fieldset>
|
|
143
155
|
</BaseControl>
|
|
@@ -20,17 +20,6 @@ const getButtonWithAriaLabelStartPredicate =
|
|
|
20
20
|
);
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
const getTabWithTestPredicate = ( text ) => ( element ) => {
|
|
24
|
-
return (
|
|
25
|
-
element.type === 'button' &&
|
|
26
|
-
element.props[ 'aria-label' ] &&
|
|
27
|
-
element.props[ 'aria-label' ] === text
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const colorTabButtonPredicate = getTabWithTestPredicate( 'Solid' );
|
|
32
|
-
const gradientTabButtonPredicate = getTabWithTestPredicate( 'Gradient' );
|
|
33
|
-
|
|
34
23
|
describe( 'ColorPaletteControl', () => {
|
|
35
24
|
it( 'renders tabs if it is possible to select a color and a gradient rendering a color picker at the start', async () => {
|
|
36
25
|
render(
|
|
@@ -63,8 +52,12 @@ describe( 'ColorPaletteControl', () => {
|
|
|
63
52
|
);
|
|
64
53
|
|
|
65
54
|
// Is showing the two tab buttons.
|
|
66
|
-
expect(
|
|
67
|
-
|
|
55
|
+
expect(
|
|
56
|
+
screen.getByRole( 'tab', { name: 'Solid color' } )
|
|
57
|
+
).toBeInTheDocument();
|
|
58
|
+
expect(
|
|
59
|
+
screen.getByRole( 'tab', { name: 'Gradient' } )
|
|
60
|
+
).toBeInTheDocument();
|
|
68
61
|
|
|
69
62
|
// Is showing the two predefined Colors.
|
|
70
63
|
expect( screen.getAllByLabelText( /^Color:/ ) ).toHaveLength( 2 );
|
|
@@ -92,12 +85,12 @@ describe( 'ColorPaletteControl', () => {
|
|
|
92
85
|
} );
|
|
93
86
|
|
|
94
87
|
// Is not showing the two tab buttons.
|
|
95
|
-
expect( wrapper.root.findAll( colorTabButtonPredicate ) ).toHaveLength(
|
|
96
|
-
0
|
|
97
|
-
);
|
|
98
88
|
expect(
|
|
99
|
-
|
|
100
|
-
).
|
|
89
|
+
screen.queryByRole( 'tab', { name: 'Solid color' } )
|
|
90
|
+
).not.toBeInTheDocument();
|
|
91
|
+
expect(
|
|
92
|
+
screen.queryByRole( 'tab', { name: 'Gradient' } )
|
|
93
|
+
).not.toBeInTheDocument();
|
|
101
94
|
|
|
102
95
|
// Is showing the two predefined Colors.
|
|
103
96
|
expect(
|
|
@@ -139,12 +132,12 @@ describe( 'ColorPaletteControl', () => {
|
|
|
139
132
|
} );
|
|
140
133
|
|
|
141
134
|
// Is not showing the two tab buttons.
|
|
142
|
-
expect( wrapper.root.findAll( colorTabButtonPredicate ) ).toHaveLength(
|
|
143
|
-
0
|
|
144
|
-
);
|
|
145
135
|
expect(
|
|
146
|
-
|
|
147
|
-
).
|
|
136
|
+
screen.queryByRole( 'tab', { name: 'Solid color' } )
|
|
137
|
+
).not.toBeInTheDocument();
|
|
138
|
+
expect(
|
|
139
|
+
screen.queryByRole( 'tab', { name: 'Gradient' } )
|
|
140
|
+
).not.toBeInTheDocument();
|
|
148
141
|
|
|
149
142
|
// Is showing the two predefined Gradients.
|
|
150
143
|
expect(
|
|
@@ -90,6 +90,7 @@ function NonDefaultControls( { format, onChange } ) {
|
|
|
90
90
|
_x( 'M j, Y', 'medium date format' ),
|
|
91
91
|
_x( 'M j, Y g:i A', 'medium date format with time' ),
|
|
92
92
|
_x( 'F j, Y', 'long date format' ),
|
|
93
|
+
_x( 'M j', 'short date format without the year' ),
|
|
93
94
|
] );
|
|
94
95
|
|
|
95
96
|
const suggestedOptions = suggestedFormats.map(
|
|
@@ -65,12 +65,31 @@ function useStylesCompatibility() {
|
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
function matchFromRules( _cssRules ) {
|
|
69
|
+
return Array.from( _cssRules ).find(
|
|
70
|
+
( {
|
|
71
|
+
selectorText,
|
|
72
|
+
conditionText,
|
|
73
|
+
cssRules: __cssRules,
|
|
74
|
+
} ) => {
|
|
75
|
+
// If the rule is conditional then it will not have selector text.
|
|
76
|
+
// Recurse into child CSS ruleset to determine selector eligibility.
|
|
77
|
+
if ( conditionText ) {
|
|
78
|
+
return matchFromRules( __cssRules );
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
selectorText &&
|
|
83
|
+
( selectorText.includes(
|
|
84
|
+
`.${ BODY_CLASS_NAME }`
|
|
85
|
+
) ||
|
|
86
|
+
selectorText.includes( `.${ BLOCK_PREFIX }` ) )
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const isMatch = matchFromRules( cssRules );
|
|
74
93
|
|
|
75
94
|
if (
|
|
76
95
|
isMatch &&
|
|
@@ -2417,10 +2417,12 @@ describe( 'Controlling link title text', () => {
|
|
|
2417
2417
|
Simulate.keyDown( textInput, { keyCode: ENTER } );
|
|
2418
2418
|
} );
|
|
2419
2419
|
|
|
2420
|
-
expect( mockOnChange ).toHaveBeenCalledWith(
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2420
|
+
expect( mockOnChange ).toHaveBeenCalledWith(
|
|
2421
|
+
expect.objectContaining( {
|
|
2422
|
+
title: textValue,
|
|
2423
|
+
url: selectedLink.url,
|
|
2424
|
+
} )
|
|
2425
|
+
);
|
|
2424
2426
|
|
|
2425
2427
|
// The text input should not be showing as the form is submitted.
|
|
2426
2428
|
expect(
|