@wordpress/block-library 6.0.20 → 6.0.26
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/gallery/constants.js +5 -1
- package/build/gallery/constants.js.map +1 -1
- package/build/gallery/transforms.js +8 -2
- package/build/gallery/transforms.js.map +1 -1
- package/build/gallery/utils.js +4 -3
- package/build/gallery/utils.js.map +1 -1
- package/build/heading/edit.js +14 -2
- package/build/heading/edit.js.map +1 -1
- package/build/navigation/edit/index.js +8 -2
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +42 -4
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +6 -41
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/use-convert-classic-menu.js +59 -0
- package/build/navigation/use-convert-classic-menu.js.map +1 -0
- package/build/page-list/edit.js +37 -10
- package/build/page-list/edit.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +50 -30
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-featured-image/edit.js +4 -2
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/site-logo/edit.js +0 -25
- package/build/site-logo/edit.js.map +1 -1
- package/build/social-links/deprecated.js +1 -62
- package/build/social-links/deprecated.js.map +1 -1
- package/build/social-links/edit.js +1 -1
- package/build/social-links/edit.js.map +1 -1
- package/build/spacer/controls.js +111 -0
- package/build/spacer/controls.js.map +1 -0
- package/build/spacer/controls.native.js +95 -0
- package/build/spacer/controls.native.js.map +1 -0
- package/build/spacer/deprecated.js +53 -0
- package/build/spacer/deprecated.js.map +1 -0
- package/build/spacer/edit.js +111 -82
- package/build/spacer/edit.js.map +1 -1
- package/build/spacer/edit.native.js +76 -0
- package/build/spacer/edit.native.js.map +1 -0
- package/build/spacer/index.js +7 -4
- package/build/spacer/index.js.map +1 -1
- package/build/spacer/save.js +6 -3
- package/build/spacer/save.js.map +1 -1
- package/build-module/gallery/constants.js +2 -0
- package/build-module/gallery/constants.js.map +1 -1
- package/build-module/gallery/transforms.js +8 -2
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/gallery/utils.js +5 -4
- package/build-module/gallery/utils.js.map +1 -1
- package/build-module/heading/edit.js +15 -3
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/navigation/edit/index.js +7 -2
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +39 -4
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +5 -41
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/use-convert-classic-menu.js +47 -0
- package/build-module/navigation/use-convert-classic-menu.js.map +1 -0
- package/build-module/page-list/edit.js +38 -11
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +52 -29
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-featured-image/edit.js +4 -2
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +0 -25
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/social-links/deprecated.js +1 -62
- package/build-module/social-links/deprecated.js.map +1 -1
- package/build-module/social-links/edit.js +1 -1
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/spacer/controls.js +101 -0
- package/build-module/spacer/controls.js.map +1 -0
- package/build-module/spacer/controls.native.js +82 -0
- package/build-module/spacer/controls.native.js.map +1 -0
- package/build-module/spacer/deprecated.js +44 -0
- package/build-module/spacer/deprecated.js.map +1 -0
- package/build-module/spacer/edit.js +108 -82
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/spacer/edit.native.js +61 -0
- package/build-module/spacer/edit.native.js.map +1 -0
- package/build-module/spacer/index.js +6 -4
- package/build-module/spacer/index.js.map +1 -1
- package/build-module/spacer/save.js +6 -3
- package/build-module/spacer/save.js.map +1 -1
- package/build-style/common-rtl.css +8 -0
- package/build-style/common.css +8 -0
- package/build-style/cover/style-rtl.css +60 -0
- package/build-style/cover/style.css +60 -0
- package/build-style/editor-rtl.css +8 -7
- package/build-style/editor.css +8 -7
- package/build-style/gallery/style-rtl.css +2 -1
- package/build-style/gallery/style.css +2 -1
- package/build-style/image/style-rtl.css +0 -2
- package/build-style/image/style.css +0 -2
- package/build-style/page-list/editor-rtl.css +4 -0
- package/build-style/page-list/editor.css +4 -0
- package/build-style/post-featured-image/editor-rtl.css +0 -7
- package/build-style/post-featured-image/editor.css +0 -7
- package/build-style/post-template/style-rtl.css +4 -0
- package/build-style/post-template/style.css +4 -0
- package/build-style/spacer/editor-rtl.css +4 -0
- package/build-style/spacer/editor.css +4 -0
- package/build-style/style-rtl.css +74 -3
- package/build-style/style.css +74 -3
- package/package.json +8 -8
- package/src/common.scss +8 -0
- package/src/cover/style.scss +13 -0
- package/src/gallery/constants.js +2 -0
- package/src/gallery/style.scss +4 -1
- package/src/gallery/transforms.js +7 -1
- package/src/gallery/utils.js +7 -3
- package/src/heading/edit.js +18 -5
- package/src/image/style.scss +0 -2
- package/src/navigation/edit/index.js +9 -1
- package/src/navigation/edit/navigation-menu-selector.js +65 -15
- package/src/navigation/edit/placeholder/index.js +9 -44
- package/src/navigation/use-convert-classic-menu.js +58 -0
- package/src/page-list/edit.js +47 -9
- package/src/page-list/editor.scss +4 -0
- package/src/page-list/index.php +5 -0
- package/src/post-featured-image/dimension-controls.js +75 -50
- package/src/post-featured-image/edit.js +6 -4
- package/src/post-featured-image/editor.scss +0 -8
- package/src/post-template/style.scss +5 -0
- package/src/search/index.php +6 -4
- package/src/site-logo/edit.js +1 -32
- package/src/site-logo/index.php +1 -1
- package/src/site-title/index.php +0 -1
- package/src/social-links/deprecated.js +0 -59
- package/src/social-links/edit.js +1 -1
- package/src/spacer/block.json +3 -3
- package/src/spacer/controls.js +108 -0
- package/src/spacer/controls.native.js +82 -0
- package/src/spacer/deprecated.js +41 -0
- package/src/spacer/edit.js +127 -113
- package/src/spacer/edit.native.js +68 -0
- package/src/spacer/editor.scss +6 -0
- package/src/spacer/index.js +2 -0
- package/src/spacer/save.js +5 -2
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classNames from 'classnames';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
4
|
import { __, _x } from '@wordpress/i18n';
|
|
10
5
|
import {
|
|
11
|
-
PanelBody,
|
|
12
6
|
__experimentalUnitControl as UnitControl,
|
|
13
|
-
Flex,
|
|
14
|
-
FlexItem,
|
|
15
7
|
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
16
8
|
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
17
9
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
10
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
18
11
|
} from '@wordpress/components';
|
|
19
|
-
import { useSetting } from '@wordpress/block-editor';
|
|
12
|
+
import { InspectorControls, useSetting } from '@wordpress/block-editor';
|
|
20
13
|
|
|
21
14
|
const SCALE_OPTIONS = (
|
|
22
15
|
<>
|
|
@@ -38,6 +31,8 @@ const SCALE_OPTIONS = (
|
|
|
38
31
|
</>
|
|
39
32
|
);
|
|
40
33
|
|
|
34
|
+
const DEFAULT_SCALE = 'cover';
|
|
35
|
+
|
|
41
36
|
const scaleHelp = {
|
|
42
37
|
cover: __(
|
|
43
38
|
'Image is scaled and cropped to fill the entire space without being distorted.'
|
|
@@ -51,6 +46,7 @@ const scaleHelp = {
|
|
|
51
46
|
};
|
|
52
47
|
|
|
53
48
|
const DimensionControls = ( {
|
|
49
|
+
clientId,
|
|
54
50
|
attributes: { width, height, scale },
|
|
55
51
|
setAttributes,
|
|
56
52
|
} ) => {
|
|
@@ -72,53 +68,82 @@ const DimensionControls = ( {
|
|
|
72
68
|
};
|
|
73
69
|
const scaleLabel = _x( 'Scale', 'Image scaling options' );
|
|
74
70
|
return (
|
|
75
|
-
<
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
)
|
|
71
|
+
<InspectorControls __experimentalGroup="dimensions">
|
|
72
|
+
<ToolsPanelItem
|
|
73
|
+
className="single-column"
|
|
74
|
+
hasValue={ () => !! height }
|
|
75
|
+
label={ __( 'Height' ) }
|
|
76
|
+
onDeselect={ () => setAttributes( { height: undefined } ) }
|
|
77
|
+
resetAllFilter={ () => ( {
|
|
78
|
+
height: undefined,
|
|
79
|
+
} ) }
|
|
80
|
+
isShownByDefault={ true }
|
|
81
|
+
panelId={ clientId }
|
|
82
|
+
>
|
|
83
|
+
<UnitControl
|
|
84
|
+
label={ __( 'Height' ) }
|
|
85
|
+
labelPosition="top"
|
|
86
|
+
value={ height || '' }
|
|
87
|
+
min={ 0 }
|
|
88
|
+
onChange={ ( nextHeight ) =>
|
|
89
|
+
onDimensionChange( 'height', nextHeight )
|
|
90
|
+
}
|
|
91
|
+
units={ units }
|
|
92
|
+
/>
|
|
93
|
+
</ToolsPanelItem>
|
|
94
|
+
<ToolsPanelItem
|
|
95
|
+
className="single-column"
|
|
96
|
+
hasValue={ () => !! width }
|
|
97
|
+
label={ __( 'Width' ) }
|
|
98
|
+
onDeselect={ () => setAttributes( { width: undefined } ) }
|
|
99
|
+
resetAllFilter={ () => ( {
|
|
100
|
+
width: undefined,
|
|
101
|
+
} ) }
|
|
102
|
+
isShownByDefault={ true }
|
|
103
|
+
panelId={ clientId }
|
|
82
104
|
>
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
<FlexItem>
|
|
95
|
-
<UnitControl
|
|
96
|
-
label={ __( 'Width' ) }
|
|
97
|
-
labelPosition="top"
|
|
98
|
-
value={ width || '' }
|
|
99
|
-
onChange={ ( nextWidth ) => {
|
|
100
|
-
onDimensionChange( 'width', nextWidth );
|
|
101
|
-
} }
|
|
102
|
-
units={ units }
|
|
103
|
-
/>
|
|
104
|
-
</FlexItem>
|
|
105
|
-
</Flex>
|
|
105
|
+
<UnitControl
|
|
106
|
+
label={ __( 'Width' ) }
|
|
107
|
+
labelPosition="top"
|
|
108
|
+
value={ width || '' }
|
|
109
|
+
min={ 0 }
|
|
110
|
+
onChange={ ( nextWidth ) =>
|
|
111
|
+
onDimensionChange( 'width', nextWidth )
|
|
112
|
+
}
|
|
113
|
+
units={ units }
|
|
114
|
+
/>
|
|
115
|
+
</ToolsPanelItem>
|
|
106
116
|
{ !! height && (
|
|
107
|
-
<
|
|
117
|
+
<ToolsPanelItem
|
|
118
|
+
hasValue={ () => !! scale && scale !== DEFAULT_SCALE }
|
|
108
119
|
label={ scaleLabel }
|
|
109
|
-
|
|
110
|
-
help={ scaleHelp[ scale ] }
|
|
111
|
-
onChange={ ( value ) => {
|
|
120
|
+
onDeselect={ () =>
|
|
112
121
|
setAttributes( {
|
|
113
|
-
scale:
|
|
114
|
-
} )
|
|
115
|
-
}
|
|
116
|
-
|
|
122
|
+
scale: DEFAULT_SCALE,
|
|
123
|
+
} )
|
|
124
|
+
}
|
|
125
|
+
resetAllFilter={ () => ( {
|
|
126
|
+
scale: DEFAULT_SCALE,
|
|
127
|
+
} ) }
|
|
128
|
+
isShownByDefault={ true }
|
|
129
|
+
panelId={ clientId }
|
|
117
130
|
>
|
|
118
|
-
|
|
119
|
-
|
|
131
|
+
<ToggleGroupControl
|
|
132
|
+
label={ scaleLabel }
|
|
133
|
+
value={ scale }
|
|
134
|
+
help={ scaleHelp[ scale ] }
|
|
135
|
+
onChange={ ( value ) =>
|
|
136
|
+
setAttributes( {
|
|
137
|
+
scale: value,
|
|
138
|
+
} )
|
|
139
|
+
}
|
|
140
|
+
isBlock
|
|
141
|
+
>
|
|
142
|
+
{ SCALE_OPTIONS }
|
|
143
|
+
</ToggleGroupControl>
|
|
144
|
+
</ToolsPanelItem>
|
|
120
145
|
) }
|
|
121
|
-
</
|
|
146
|
+
</InspectorControls>
|
|
122
147
|
);
|
|
123
148
|
};
|
|
124
149
|
|
|
@@ -46,6 +46,7 @@ const placeholderChip = (
|
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
function PostFeaturedImageDisplay( {
|
|
49
|
+
clientId,
|
|
49
50
|
attributes,
|
|
50
51
|
setAttributes,
|
|
51
52
|
context: { postId, postType, queryId },
|
|
@@ -136,11 +137,12 @@ function PostFeaturedImageDisplay( {
|
|
|
136
137
|
|
|
137
138
|
return (
|
|
138
139
|
<>
|
|
140
|
+
<DimensionControls
|
|
141
|
+
clientId={ clientId }
|
|
142
|
+
attributes={ attributes }
|
|
143
|
+
setAttributes={ setAttributes }
|
|
144
|
+
/>
|
|
139
145
|
<InspectorControls>
|
|
140
|
-
<DimensionControls
|
|
141
|
-
attributes={ attributes }
|
|
142
|
-
setAttributes={ setAttributes }
|
|
143
|
-
/>
|
|
144
146
|
<PanelBody title={ __( 'Link settings' ) }>
|
|
145
147
|
<ToggleControl
|
|
146
148
|
label={ sprintf(
|
|
@@ -128,11 +128,3 @@ div[data-type="core/post-featured-image"] {
|
|
|
128
128
|
display: block;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
|
|
132
|
-
.block-library-post-featured-image-dimension-controls {
|
|
133
|
-
margin-bottom: $grid-unit-10;
|
|
134
|
-
|
|
135
|
-
&.scale-control-is-visible {
|
|
136
|
-
margin-bottom: $grid-unit-20;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
list-style: none;
|
|
12
12
|
padding: 0;
|
|
13
13
|
|
|
14
|
+
// Unset background colors that can be inherited from Global Styles with extra specificity.
|
|
15
|
+
&.wp-block-post-template {
|
|
16
|
+
background: none;
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
&.is-flex-container {
|
|
15
20
|
flex-direction: row;
|
|
16
21
|
display: flex;
|
package/src/search/index.php
CHANGED
|
@@ -43,16 +43,18 @@ function render_block_core_search( $attributes ) {
|
|
|
43
43
|
// Border color classes need to be applied to the elements that have a border color.
|
|
44
44
|
$border_color_classes = get_border_color_classes_for_block_core_search( $attributes );
|
|
45
45
|
|
|
46
|
+
$label_inner_html = empty( $attributes['label'] ) ? __( 'Search' ) : wp_kses_post( $attributes['label'] );
|
|
47
|
+
|
|
46
48
|
$label_markup = sprintf(
|
|
47
49
|
'<label for="%1$s" class="wp-block-search__label screen-reader-text">%2$s</label>',
|
|
48
|
-
$input_id,
|
|
49
|
-
|
|
50
|
+
esc_attr( $input_id ),
|
|
51
|
+
$label_inner_html
|
|
50
52
|
);
|
|
51
53
|
if ( $show_label && ! empty( $attributes['label'] ) ) {
|
|
52
54
|
$label_markup = sprintf(
|
|
53
55
|
'<label for="%1$s" class="wp-block-search__label">%2$s</label>',
|
|
54
56
|
$input_id,
|
|
55
|
-
|
|
57
|
+
$label_inner_html
|
|
56
58
|
);
|
|
57
59
|
}
|
|
58
60
|
|
|
@@ -77,7 +79,7 @@ function render_block_core_search( $attributes ) {
|
|
|
77
79
|
}
|
|
78
80
|
if ( ! $use_icon_button ) {
|
|
79
81
|
if ( ! empty( $attributes['buttonText'] ) ) {
|
|
80
|
-
$button_internal_markup =
|
|
82
|
+
$button_internal_markup = wp_kses_post( $attributes['buttonText'] );
|
|
81
83
|
}
|
|
82
84
|
} else {
|
|
83
85
|
$button_classes .= ' has-icon';
|
package/src/site-logo/edit.js
CHANGED
|
@@ -358,7 +358,7 @@ export default function LogoEdit( {
|
|
|
358
358
|
setAttributes,
|
|
359
359
|
isSelected,
|
|
360
360
|
} ) {
|
|
361
|
-
const {
|
|
361
|
+
const { width, shouldSyncIcon } = attributes;
|
|
362
362
|
const [ logoUrl, setLogoUrl ] = useState();
|
|
363
363
|
const ref = useRef();
|
|
364
364
|
|
|
@@ -406,39 +406,8 @@ export default function LogoEdit( {
|
|
|
406
406
|
};
|
|
407
407
|
}, [] );
|
|
408
408
|
|
|
409
|
-
const { getGlobalBlockCount } = useSelect( blockEditorStore );
|
|
410
409
|
const { editEntityRecord } = useDispatch( coreStore );
|
|
411
410
|
|
|
412
|
-
useEffect( () => {
|
|
413
|
-
// Cleanup function to discard unsaved changes to the icon and logo when
|
|
414
|
-
// the block is removed.
|
|
415
|
-
return () => {
|
|
416
|
-
// Do nothing if the block is being rendered in the styles preview or the
|
|
417
|
-
// block inserter.
|
|
418
|
-
if (
|
|
419
|
-
styleClass?.includes(
|
|
420
|
-
'block-editor-block-types-list__site-logo-example'
|
|
421
|
-
) ||
|
|
422
|
-
styleClass?.includes(
|
|
423
|
-
'block-editor-block-styles__block-preview-container'
|
|
424
|
-
)
|
|
425
|
-
) {
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
const logoBlockCount = getGlobalBlockCount( 'core/site-logo' );
|
|
430
|
-
|
|
431
|
-
// Only discard unsaved changes if we are removing the last Site Logo block
|
|
432
|
-
// on the page.
|
|
433
|
-
if ( logoBlockCount === 0 ) {
|
|
434
|
-
editEntityRecord( 'root', 'site', undefined, {
|
|
435
|
-
site_logo: undefined,
|
|
436
|
-
site_icon: undefined,
|
|
437
|
-
} );
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
}, [] );
|
|
441
|
-
|
|
442
411
|
const setLogo = ( newValue, shouldForceSync = false ) => {
|
|
443
412
|
// `shouldForceSync` is used to force syncing when the attribute
|
|
444
413
|
// may not have updated yet.
|
package/src/site-logo/index.php
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
function render_block_core_site_logo( $attributes ) {
|
|
16
16
|
$adjust_width_height_filter = function ( $image ) use ( $attributes ) {
|
|
17
|
-
if ( empty( $attributes['width'] ) || empty( $image ) ) {
|
|
17
|
+
if ( empty( $attributes['width'] ) || empty( $image ) || ! $image[1] || ! $image[2] ) {
|
|
18
18
|
return $image;
|
|
19
19
|
}
|
|
20
20
|
$height = (float) $attributes['width'] / ( (float) $image[1] / (float) $image[2] );
|
package/src/site-title/index.php
CHANGED
|
@@ -35,7 +35,6 @@ function render_block_core_site_title( $attributes ) {
|
|
|
35
35
|
);
|
|
36
36
|
if ( '_blank' === $attributes['linkTarget'] ) {
|
|
37
37
|
$link_attrs[] = 'target="_blank"';
|
|
38
|
-
$link_attrs[] = 'aria-label="' . esc_attr__( '(opens in a new tab)' ) . '"';
|
|
39
38
|
}
|
|
40
39
|
$site_title = sprintf( '<a %1$s>%2$s</a>', implode( ' ', $link_attrs ), $site_title );
|
|
41
40
|
}
|
|
@@ -49,65 +49,6 @@ const migrateWithLayout = ( attributes ) => {
|
|
|
49
49
|
|
|
50
50
|
// Social Links block deprecations.
|
|
51
51
|
const deprecated = [
|
|
52
|
-
// Implement `flex` layout.
|
|
53
|
-
{
|
|
54
|
-
attributes: {
|
|
55
|
-
iconColor: {
|
|
56
|
-
type: 'string',
|
|
57
|
-
},
|
|
58
|
-
customIconColor: {
|
|
59
|
-
type: 'string',
|
|
60
|
-
},
|
|
61
|
-
iconColorValue: {
|
|
62
|
-
type: 'string',
|
|
63
|
-
},
|
|
64
|
-
iconBackgroundColor: {
|
|
65
|
-
type: 'string',
|
|
66
|
-
},
|
|
67
|
-
customIconBackgroundColor: {
|
|
68
|
-
type: 'string',
|
|
69
|
-
},
|
|
70
|
-
iconBackgroundColorValue: {
|
|
71
|
-
type: 'string',
|
|
72
|
-
},
|
|
73
|
-
openInNewTab: {
|
|
74
|
-
type: 'boolean',
|
|
75
|
-
default: false,
|
|
76
|
-
},
|
|
77
|
-
size: {
|
|
78
|
-
type: 'string',
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
supports: {
|
|
82
|
-
align: [ 'left', 'center', 'right' ],
|
|
83
|
-
anchor: true,
|
|
84
|
-
__experimentalExposeControlsToChildren: true,
|
|
85
|
-
},
|
|
86
|
-
isEligible: ( { layout } ) => ! layout,
|
|
87
|
-
migrate: migrateWithLayout,
|
|
88
|
-
save( props ) {
|
|
89
|
-
const {
|
|
90
|
-
attributes: {
|
|
91
|
-
iconBackgroundColorValue,
|
|
92
|
-
iconColorValue,
|
|
93
|
-
itemsJustification,
|
|
94
|
-
size,
|
|
95
|
-
},
|
|
96
|
-
} = props;
|
|
97
|
-
|
|
98
|
-
const className = classNames( size, {
|
|
99
|
-
'has-icon-color': iconColorValue,
|
|
100
|
-
'has-icon-background-color': iconBackgroundColorValue,
|
|
101
|
-
[ `items-justified-${ itemsJustification }` ]: itemsJustification,
|
|
102
|
-
} );
|
|
103
|
-
|
|
104
|
-
return (
|
|
105
|
-
<ul { ...useBlockProps.save( { className } ) }>
|
|
106
|
-
<InnerBlocks.Content />
|
|
107
|
-
</ul>
|
|
108
|
-
);
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
52
|
// V1. Remove CSS variable use for colors.
|
|
112
53
|
{
|
|
113
54
|
attributes: {
|
package/src/social-links/edit.js
CHANGED
package/src/spacer/block.json
CHANGED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { InspectorControls, useSetting } from '@wordpress/block-editor';
|
|
6
|
+
import {
|
|
7
|
+
BaseControl,
|
|
8
|
+
PanelBody,
|
|
9
|
+
__experimentalUseCustomUnits as useCustomUnits,
|
|
10
|
+
__experimentalUnitControl as UnitControl,
|
|
11
|
+
} from '@wordpress/components';
|
|
12
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
13
|
+
import { useState } from '@wordpress/element';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import { MAX_SPACER_SIZE } from './edit';
|
|
19
|
+
|
|
20
|
+
function DimensionInput( { label, onChange, isResizing, value = '' } ) {
|
|
21
|
+
const [ temporaryInput, setTemporaryInput ] = useState( null );
|
|
22
|
+
|
|
23
|
+
const inputId = useInstanceId( UnitControl, 'block-spacer-height-input' );
|
|
24
|
+
|
|
25
|
+
// In most contexts the spacer size cannot meaningfully be set to a
|
|
26
|
+
// percentage, since this is relative to the parent container. This
|
|
27
|
+
// unit is disabled from the UI.
|
|
28
|
+
const availableUnitSettings = (
|
|
29
|
+
useSetting( 'spacing.units' ) || undefined
|
|
30
|
+
)?.filter( ( availableUnit ) => availableUnit !== '%' );
|
|
31
|
+
|
|
32
|
+
const units = useCustomUnits( {
|
|
33
|
+
availableUnits: availableUnitSettings || [
|
|
34
|
+
'px',
|
|
35
|
+
'em',
|
|
36
|
+
'rem',
|
|
37
|
+
'vw',
|
|
38
|
+
'vh',
|
|
39
|
+
],
|
|
40
|
+
defaultValues: { px: '100', em: '10', rem: '10', vw: '10', vh: '25' },
|
|
41
|
+
} );
|
|
42
|
+
|
|
43
|
+
const handleOnChange = ( unprocessedValue ) => {
|
|
44
|
+
setTemporaryInput( null );
|
|
45
|
+
onChange( unprocessedValue );
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const handleOnBlur = () => {
|
|
49
|
+
if ( temporaryInput !== null ) {
|
|
50
|
+
setTemporaryInput( null );
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const inputValue = temporaryInput !== null ? temporaryInput : value;
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<BaseControl label={ label } id={ inputId }>
|
|
58
|
+
<UnitControl
|
|
59
|
+
id={ inputId }
|
|
60
|
+
isResetValueOnUnitChange
|
|
61
|
+
min={ 0 }
|
|
62
|
+
max={ MAX_SPACER_SIZE }
|
|
63
|
+
onBlur={ handleOnBlur }
|
|
64
|
+
onChange={ handleOnChange }
|
|
65
|
+
style={ { maxWidth: 80 } }
|
|
66
|
+
value={ inputValue }
|
|
67
|
+
units={ units }
|
|
68
|
+
// Force the unit to update to `px` when the Spacer is being resized.
|
|
69
|
+
unit={ isResizing ? 'px' : undefined }
|
|
70
|
+
/>
|
|
71
|
+
</BaseControl>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default function SpacerControls( {
|
|
76
|
+
setAttributes,
|
|
77
|
+
orientation,
|
|
78
|
+
height,
|
|
79
|
+
width,
|
|
80
|
+
isResizing,
|
|
81
|
+
} ) {
|
|
82
|
+
return (
|
|
83
|
+
<InspectorControls>
|
|
84
|
+
<PanelBody title={ __( 'Spacer settings' ) }>
|
|
85
|
+
{ orientation === 'horizontal' && (
|
|
86
|
+
<DimensionInput
|
|
87
|
+
label={ __( 'Width' ) }
|
|
88
|
+
value={ width }
|
|
89
|
+
onChange={ ( nextWidth ) =>
|
|
90
|
+
setAttributes( { width: nextWidth } )
|
|
91
|
+
}
|
|
92
|
+
isResizing={ isResizing }
|
|
93
|
+
/>
|
|
94
|
+
) }
|
|
95
|
+
{ orientation !== 'horizontal' && (
|
|
96
|
+
<DimensionInput
|
|
97
|
+
label={ __( 'Height' ) }
|
|
98
|
+
value={ height }
|
|
99
|
+
onChange={ ( nextHeight ) =>
|
|
100
|
+
setAttributes( { height: nextHeight } )
|
|
101
|
+
}
|
|
102
|
+
isResizing={ isResizing }
|
|
103
|
+
/>
|
|
104
|
+
) }
|
|
105
|
+
</PanelBody>
|
|
106
|
+
</InspectorControls>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
PanelBody,
|
|
6
|
+
UnitControl,
|
|
7
|
+
getValueAndUnit,
|
|
8
|
+
__experimentalUseCustomUnits as useCustomUnits,
|
|
9
|
+
} from '@wordpress/components';
|
|
10
|
+
import { useCallback } from '@wordpress/element';
|
|
11
|
+
import { useSetting } from '@wordpress/block-editor';
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
import styles from './style.scss';
|
|
18
|
+
|
|
19
|
+
const DEFAULT_VALUES = { px: '100', em: '10', rem: '10', vw: '10', vh: '25' };
|
|
20
|
+
|
|
21
|
+
function Controls( { attributes, context, setAttributes } ) {
|
|
22
|
+
const { orientation } = context;
|
|
23
|
+
const label = orientation !== 'horizontal' ? __( 'Height' ) : __( 'Width' );
|
|
24
|
+
|
|
25
|
+
const { height, width } = attributes;
|
|
26
|
+
const { valueToConvert, valueUnit: unit } =
|
|
27
|
+
getValueAndUnit( orientation !== 'horizontal' ? height : width ) || {};
|
|
28
|
+
const value = Number( valueToConvert );
|
|
29
|
+
|
|
30
|
+
const setNewDimensions = ( nextValue, nextUnit ) => {
|
|
31
|
+
const valueWithUnit = `${ nextValue }${ nextUnit }`;
|
|
32
|
+
if ( orientation === 'horizontal' ) {
|
|
33
|
+
setAttributes( { width: valueWithUnit } );
|
|
34
|
+
} else {
|
|
35
|
+
setAttributes( { height: valueWithUnit } );
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const handleChange = useCallback(
|
|
40
|
+
( nextValue ) => {
|
|
41
|
+
setNewDimensions( nextValue, unit );
|
|
42
|
+
},
|
|
43
|
+
[ height, width ]
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const handleUnitChange = useCallback(
|
|
47
|
+
( nextUnit ) => {
|
|
48
|
+
setNewDimensions( value, nextUnit );
|
|
49
|
+
},
|
|
50
|
+
[ height, width ]
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const units = useCustomUnits( {
|
|
54
|
+
availableUnits: useSetting( 'spacing.units' ) || [
|
|
55
|
+
'px',
|
|
56
|
+
'em',
|
|
57
|
+
'rem',
|
|
58
|
+
'vw',
|
|
59
|
+
'vh',
|
|
60
|
+
],
|
|
61
|
+
defaultValues: DEFAULT_VALUES,
|
|
62
|
+
} );
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
<PanelBody title={ __( 'Dimensions' ) }>
|
|
67
|
+
<UnitControl
|
|
68
|
+
label={ label }
|
|
69
|
+
min={ 1 }
|
|
70
|
+
value={ value }
|
|
71
|
+
onChange={ handleChange }
|
|
72
|
+
onUnitChange={ handleUnitChange }
|
|
73
|
+
units={ units }
|
|
74
|
+
unit={ unit }
|
|
75
|
+
style={ styles.rangeCellContainer }
|
|
76
|
+
/>
|
|
77
|
+
</PanelBody>
|
|
78
|
+
</>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default Controls;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useBlockProps } from '@wordpress/block-editor';
|
|
5
|
+
|
|
6
|
+
const deprecated = [
|
|
7
|
+
{
|
|
8
|
+
attributes: {
|
|
9
|
+
height: {
|
|
10
|
+
type: 'number',
|
|
11
|
+
default: 100,
|
|
12
|
+
},
|
|
13
|
+
width: {
|
|
14
|
+
type: 'number',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
migrate( attributes ) {
|
|
18
|
+
const { height, width } = attributes;
|
|
19
|
+
return {
|
|
20
|
+
...attributes,
|
|
21
|
+
width: width !== undefined ? `${ width }px` : undefined,
|
|
22
|
+
height: height !== undefined ? `${ height }px` : undefined,
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
save( { attributes } ) {
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
{ ...useBlockProps.save( {
|
|
29
|
+
style: {
|
|
30
|
+
height: attributes.height,
|
|
31
|
+
width: attributes.width,
|
|
32
|
+
},
|
|
33
|
+
'aria-hidden': true,
|
|
34
|
+
} ) }
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
export default deprecated;
|