@wordpress/block-library 8.21.0 → 8.22.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/build/avatar/index.js +5 -1
- package/build/avatar/index.js.map +1 -1
- package/build/block/edit-title.native.js +11 -3
- package/build/block/edit-title.native.js.map +1 -1
- package/build/block/edit.js +3 -3
- package/build/block/edit.js.map +1 -1
- package/build/column/edit.js +2 -1
- package/build/column/edit.js.map +1 -1
- package/build/column/edit.native.js +2 -1
- package/build/column/edit.native.js.map +1 -1
- package/build/columns/edit.native.js +2 -1
- package/build/columns/edit.native.js.map +1 -1
- package/build/cover/controls.native.js +2 -1
- package/build/cover/controls.native.js.map +1 -1
- package/build/cover/edit/index.js +2 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +2 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/file/view.js +1 -1
- package/build/file/view.js.map +1 -1
- package/build/form/edit.js +2 -2
- package/build/form/edit.js.map +1 -1
- package/build/form/index.js +25 -5
- package/build/form/index.js.map +1 -1
- package/build/form/variations.js +1 -1
- package/build/form/variations.js.map +1 -1
- package/build/form-input/index.js +2 -2
- package/build/form-input/index.js.map +1 -1
- package/build/form-input/variations.js +7 -7
- package/build/form-input/variations.js.map +1 -1
- package/build/form-submission-notification/index.js +1 -1
- package/build/form-submission-notification/index.js.map +1 -1
- package/build/form-submission-notification/variations.js +4 -4
- package/build/form-submission-notification/variations.js.map +1 -1
- package/build/form-submit-button/index.js +2 -2
- package/build/form-submit-button/index.js.map +1 -1
- package/build/group/edit.js +2 -11
- package/build/group/edit.js.map +1 -1
- package/build/html/preview.js +2 -4
- package/build/html/preview.js.map +1 -1
- package/build/image/image.js +11 -5
- package/build/image/image.js.map +1 -1
- package/build/image/view.js +10 -20
- package/build/image/view.js.map +1 -1
- package/build/missing/edit.native.js +46 -8
- package/build/missing/edit.native.js.map +1 -1
- package/build/paragraph/edit.js +1 -1
- package/build/paragraph/edit.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +2 -2
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-terms/edit.js +2 -2
- package/build/post-terms/edit.js.map +1 -1
- package/build/query/edit/enhanced-pagination-modal.js +27 -13
- package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js +15 -12
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build/query/utils.js +29 -8
- package/build/query/utils.js.map +1 -1
- package/build/query/view.js +4 -2
- package/build/query/view.js.map +1 -1
- package/build/search/edit.js +1 -2
- package/build/search/edit.js.map +1 -1
- package/build/social-link/edit.native.js +7 -19
- package/build/social-link/edit.native.js.map +1 -1
- package/build/spacer/controls.js +3 -3
- package/build/spacer/controls.js.map +1 -1
- package/build/spacer/controls.native.js +2 -1
- package/build/spacer/controls.native.js.map +1 -1
- package/build/spacer/edit.js +1 -1
- package/build/spacer/edit.js.map +1 -1
- package/build/spacer/edit.native.js +5 -1
- package/build/spacer/edit.native.js.map +1 -1
- package/build/tag-cloud/edit.js +2 -1
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/template-part/edit/inner-blocks.js +2 -2
- package/build/template-part/edit/inner-blocks.js.map +1 -1
- package/build/term-description/index.js +0 -1
- package/build/term-description/index.js.map +1 -1
- package/build-module/avatar/index.js +5 -1
- package/build-module/avatar/index.js.map +1 -1
- package/build-module/block/edit-title.native.js +12 -4
- package/build-module/block/edit-title.native.js.map +1 -1
- package/build-module/block/edit.js +3 -3
- package/build-module/block/edit.js.map +1 -1
- package/build-module/column/edit.js +3 -2
- package/build-module/column/edit.js.map +1 -1
- package/build-module/column/edit.native.js +3 -2
- package/build-module/column/edit.native.js.map +1 -1
- package/build-module/columns/edit.native.js +3 -2
- package/build-module/columns/edit.native.js.map +1 -1
- package/build-module/cover/controls.native.js +3 -2
- package/build-module/cover/controls.native.js.map +1 -1
- package/build-module/cover/edit/index.js +3 -2
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +3 -2
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/file/view.js +2 -2
- package/build-module/file/view.js.map +1 -1
- package/build-module/form/edit.js +2 -2
- package/build-module/form/edit.js.map +1 -1
- package/build-module/form/index.js +29 -5
- package/build-module/form/index.js.map +1 -1
- package/build-module/form/variations.js +1 -1
- package/build-module/form/variations.js.map +1 -1
- package/build-module/form-input/index.js +2 -2
- package/build-module/form-input/index.js.map +1 -1
- package/build-module/form-input/variations.js +7 -7
- package/build-module/form-input/variations.js.map +1 -1
- package/build-module/form-submission-notification/index.js +1 -1
- package/build-module/form-submission-notification/index.js.map +1 -1
- package/build-module/form-submission-notification/variations.js +4 -4
- package/build-module/form-submission-notification/variations.js.map +1 -1
- package/build-module/form-submit-button/index.js +2 -2
- package/build-module/form-submit-button/index.js.map +1 -1
- package/build-module/group/edit.js +3 -12
- package/build-module/group/edit.js.map +1 -1
- package/build-module/html/preview.js +2 -4
- package/build-module/html/preview.js.map +1 -1
- package/build-module/image/image.js +12 -6
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/view.js +10 -20
- package/build-module/image/view.js.map +1 -1
- package/build-module/missing/edit.native.js +47 -9
- package/build-module/missing/edit.native.js.map +1 -1
- package/build-module/paragraph/edit.js +2 -2
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +3 -3
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-terms/edit.js +2 -2
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/query/edit/enhanced-pagination-modal.js +28 -14
- package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +17 -14
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build-module/query/utils.js +27 -5
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query/view.js +4 -2
- package/build-module/query/view.js.map +1 -1
- package/build-module/search/edit.js +2 -3
- package/build-module/search/edit.js.map +1 -1
- package/build-module/social-link/edit.native.js +8 -20
- package/build-module/social-link/edit.native.js.map +1 -1
- package/build-module/spacer/controls.js +4 -4
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/spacer/controls.native.js +3 -2
- package/build-module/spacer/controls.native.js.map +1 -1
- package/build-module/spacer/edit.js +2 -2
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/spacer/edit.native.js +6 -2
- package/build-module/spacer/edit.native.js.map +1 -1
- package/build-module/tag-cloud/edit.js +3 -2
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/template-part/edit/inner-blocks.js +3 -3
- package/build-module/template-part/edit/inner-blocks.js.map +1 -1
- package/build-module/term-description/index.js +0 -1
- package/build-module/term-description/index.js.map +1 -1
- package/build-style/file/style-rtl.css +0 -5
- package/build-style/file/style.css +0 -5
- package/build-style/navigation/style-rtl.css +5 -0
- package/build-style/navigation/style.css +5 -0
- package/build-style/style-rtl.css +5 -5
- package/build-style/style.css +5 -5
- package/package.json +32 -32
- package/src/avatar/block.json +5 -1
- package/src/block/edit-title.native.js +16 -13
- package/src/block/edit.js +1 -1
- package/src/calendar/index.php +2 -6
- package/src/column/edit.js +3 -8
- package/src/column/edit.native.js +3 -8
- package/src/columns/edit.native.js +3 -8
- package/src/comment-author-avatar/index.php +1 -1
- package/src/cover/controls.native.js +3 -8
- package/src/cover/edit/index.js +3 -2
- package/src/cover/edit/inspector-controls.js +3 -8
- package/src/file/index.php +2 -1
- package/src/file/style.scss +0 -6
- package/src/file/view.js +2 -2
- package/src/form/edit.js +3 -1
- package/src/form/index.js +38 -1
- package/src/form/variations.js +1 -1
- package/src/form-input/block.json +2 -2
- package/src/form-input/variations.js +7 -7
- package/src/form-submission-notification/block.json +1 -1
- package/src/form-submission-notification/variations.js +4 -4
- package/src/form-submit-button/block.json +2 -2
- package/src/freeform/test/__snapshots__/index.native.js.snap +7 -0
- package/src/freeform/test/index.native.js +57 -0
- package/src/group/edit.js +2 -7
- package/src/html/preview.js +9 -4
- package/src/image/image.js +17 -6
- package/src/image/index.php +5 -6
- package/src/image/view.js +13 -19
- package/src/missing/edit.native.js +43 -6
- package/src/navigation/index.php +1 -1
- package/src/navigation/style.scss +6 -1
- package/src/paragraph/edit.js +2 -2
- package/src/post-featured-image/dimension-controls.js +3 -3
- package/src/post-terms/edit.js +2 -2
- package/src/query/edit/enhanced-pagination-modal.js +37 -21
- package/src/query/edit/inspector-controls/enhanced-pagination-control.js +18 -22
- package/src/query/index.php +97 -8
- package/src/query/utils.js +29 -8
- package/src/query/view.js +11 -2
- package/src/query-pagination-next/index.php +1 -1
- package/src/query-pagination-previous/index.php +1 -1
- package/src/search/edit.js +5 -3
- package/src/social-link/edit.native.js +12 -26
- package/src/social-link/editor.native.scss +0 -9
- package/src/social-link/index.php +2 -2
- package/src/spacer/controls.js +9 -12
- package/src/spacer/controls.native.js +3 -8
- package/src/spacer/edit.js +2 -2
- package/src/spacer/edit.native.js +6 -5
- package/src/tag-cloud/edit.js +3 -7
- package/src/template-part/edit/inner-blocks.js +3 -3
- package/src/term-description/block.json +0 -1
package/src/block/edit.js
CHANGED
|
@@ -35,6 +35,7 @@ import { useRef, useMemo } from '@wordpress/element';
|
|
|
35
35
|
*/
|
|
36
36
|
import { unlock } from '../lock-unlock';
|
|
37
37
|
|
|
38
|
+
const { useLayoutClasses } = unlock( blockEditorPrivateApis );
|
|
38
39
|
const fullAlignments = [ 'full', 'wide', 'left', 'right' ];
|
|
39
40
|
|
|
40
41
|
const useInferredLayout = ( blocks, parentLayout ) => {
|
|
@@ -71,7 +72,6 @@ export default function ReusableBlockEdit( {
|
|
|
71
72
|
attributes: { ref },
|
|
72
73
|
__unstableParentLayout: parentLayout,
|
|
73
74
|
} ) {
|
|
74
|
-
const { useLayoutClasses } = unlock( blockEditorPrivateApis );
|
|
75
75
|
const hasAlreadyRendered = useHasRecursion( ref );
|
|
76
76
|
const { record, hasResolved } = useEntityRecord(
|
|
77
77
|
'postType',
|
package/src/calendar/index.php
CHANGED
|
@@ -33,10 +33,8 @@ function render_block_core_calendar( $attributes ) {
|
|
|
33
33
|
str_contains( $permalink_structure, '%monthnum%' ) &&
|
|
34
34
|
str_contains( $permalink_structure, '%year%' )
|
|
35
35
|
) {
|
|
36
|
-
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
|
|
37
36
|
$monthnum = $attributes['month'];
|
|
38
|
-
|
|
39
|
-
$year = $attributes['year'];
|
|
37
|
+
$year = $attributes['year'];
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
|
|
@@ -70,10 +68,8 @@ function render_block_core_calendar( $attributes ) {
|
|
|
70
68
|
$calendar
|
|
71
69
|
);
|
|
72
70
|
|
|
73
|
-
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
|
|
74
71
|
$monthnum = $previous_monthnum;
|
|
75
|
-
|
|
76
|
-
$year = $previous_year;
|
|
72
|
+
$year = $previous_year;
|
|
77
73
|
|
|
78
74
|
return $output;
|
|
79
75
|
}
|
package/src/column/edit.js
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
BlockVerticalAlignmentToolbar,
|
|
13
13
|
InspectorControls,
|
|
14
14
|
useBlockProps,
|
|
15
|
-
|
|
15
|
+
useSettings,
|
|
16
16
|
useInnerBlocksProps,
|
|
17
17
|
store as blockEditorStore,
|
|
18
18
|
} from '@wordpress/block-editor';
|
|
@@ -33,14 +33,9 @@ function ColumnEdit( {
|
|
|
33
33
|
[ `is-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,
|
|
34
34
|
} );
|
|
35
35
|
|
|
36
|
+
const [ availableUnits ] = useSettings( 'spacing.units' );
|
|
36
37
|
const units = useCustomUnits( {
|
|
37
|
-
availableUnits:
|
|
38
|
-
'%',
|
|
39
|
-
'px',
|
|
40
|
-
'em',
|
|
41
|
-
'rem',
|
|
42
|
-
'vw',
|
|
43
|
-
],
|
|
38
|
+
availableUnits: availableUnits || [ '%', 'px', 'em', 'rem', 'vw' ],
|
|
44
39
|
} );
|
|
45
40
|
|
|
46
41
|
const { columnsIds, hasChildBlocks, rootClientId } = useSelect(
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
BlockVerticalAlignmentToolbar,
|
|
16
16
|
InspectorControls,
|
|
17
17
|
store as blockEditorStore,
|
|
18
|
-
|
|
18
|
+
useSettings,
|
|
19
19
|
} from '@wordpress/block-editor';
|
|
20
20
|
import {
|
|
21
21
|
PanelBody,
|
|
@@ -60,14 +60,9 @@ function ColumnEdit( {
|
|
|
60
60
|
|
|
61
61
|
const [ widthUnit, setWidthUnit ] = useState( valueUnit || '%' );
|
|
62
62
|
|
|
63
|
+
const [ availableUnits ] = useSettings( 'spacing.units' );
|
|
63
64
|
const units = useCustomUnits( {
|
|
64
|
-
availableUnits:
|
|
65
|
-
'%',
|
|
66
|
-
'px',
|
|
67
|
-
'em',
|
|
68
|
-
'rem',
|
|
69
|
-
'vw',
|
|
70
|
-
],
|
|
65
|
+
availableUnits: availableUnits || [ '%', 'px', 'em', 'rem', 'vw' ],
|
|
71
66
|
} );
|
|
72
67
|
|
|
73
68
|
const updateAlignment = ( alignment ) => {
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
BlockControls,
|
|
24
24
|
BlockVerticalAlignmentToolbar,
|
|
25
25
|
BlockVariationPicker,
|
|
26
|
-
|
|
26
|
+
useSettings,
|
|
27
27
|
store as blockEditorStore,
|
|
28
28
|
} from '@wordpress/block-editor';
|
|
29
29
|
import { withDispatch, useSelect } from '@wordpress/data';
|
|
@@ -106,14 +106,9 @@ function ColumnsEditContainer( {
|
|
|
106
106
|
const { verticalAlignment, align } = attributes;
|
|
107
107
|
const { width } = sizes || {};
|
|
108
108
|
|
|
109
|
+
const [ availableUnits ] = useSettings( 'spacing.units' );
|
|
109
110
|
const units = useCustomUnits( {
|
|
110
|
-
availableUnits:
|
|
111
|
-
'%',
|
|
112
|
-
'px',
|
|
113
|
-
'em',
|
|
114
|
-
'rem',
|
|
115
|
-
'vw',
|
|
116
|
-
],
|
|
111
|
+
availableUnits: availableUnits || [ '%', 'px', 'em', 'rem', 'vw' ],
|
|
117
112
|
} );
|
|
118
113
|
|
|
119
114
|
useEffect( () => {
|
|
@@ -23,7 +23,7 @@ function render_block_core_comment_author_avatar( $attributes, $content, $block
|
|
|
23
23
|
return '';
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
// This is the only way to
|
|
26
|
+
// This is the only way to retrieve style and classes on different instances.
|
|
27
27
|
$wrapper_attributes = WP_Block_Supports::get_instance()->apply_block_supports();
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
import { plus } from '@wordpress/icons';
|
|
23
23
|
import { useState, useCallback, useRef } from '@wordpress/element';
|
|
24
24
|
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
25
|
-
import {
|
|
25
|
+
import { useSettings, MediaUpload } from '@wordpress/block-editor';
|
|
26
26
|
import { __ } from '@wordpress/i18n';
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -68,14 +68,9 @@ function Controls( {
|
|
|
68
68
|
[ minHeight ]
|
|
69
69
|
);
|
|
70
70
|
|
|
71
|
+
const [ availableUnits ] = useSettings( 'spacing.units' );
|
|
71
72
|
const units = useCustomUnits( {
|
|
72
|
-
availableUnits:
|
|
73
|
-
'px',
|
|
74
|
-
'em',
|
|
75
|
-
'rem',
|
|
76
|
-
'vw',
|
|
77
|
-
'vh',
|
|
78
|
-
],
|
|
73
|
+
availableUnits: availableUnits || [ 'px', 'em', 'rem', 'vw', 'vh' ],
|
|
79
74
|
defaultValues: { px: 430, em: 20, rem: 20, vw: 20, vh: 50 },
|
|
80
75
|
} );
|
|
81
76
|
|
package/src/cover/edit/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
withColors,
|
|
15
15
|
ColorPalette,
|
|
16
16
|
useBlockProps,
|
|
17
|
-
|
|
17
|
+
useSettings,
|
|
18
18
|
useInnerBlocksProps,
|
|
19
19
|
__experimentalUseGradient,
|
|
20
20
|
store as blockEditorStore,
|
|
@@ -318,7 +318,8 @@ function CoverEdit( {
|
|
|
318
318
|
const blockProps = useBlockProps( { ref } );
|
|
319
319
|
|
|
320
320
|
// Check for fontSize support before we pass a fontSize attribute to the innerBlocks.
|
|
321
|
-
const
|
|
321
|
+
const [ fontSizes ] = useSettings( 'typography.fontSizes' );
|
|
322
|
+
const hasFontSizes = fontSizes?.length > 0;
|
|
322
323
|
const innerBlocksTemplate = getInnerBlocksTemplate( {
|
|
323
324
|
fontSize: hasFontSizes ? 'large' : undefined,
|
|
324
325
|
} );
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
import { useInstanceId } from '@wordpress/compose';
|
|
21
21
|
import {
|
|
22
22
|
InspectorControls,
|
|
23
|
-
|
|
23
|
+
useSettings,
|
|
24
24
|
__experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,
|
|
25
25
|
__experimentalUseGradient,
|
|
26
26
|
__experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,
|
|
@@ -42,14 +42,9 @@ function CoverHeightInput( {
|
|
|
42
42
|
const inputId = `block-cover-height-input-${ instanceId }`;
|
|
43
43
|
const isPx = unit === 'px';
|
|
44
44
|
|
|
45
|
+
const [ availableUnits ] = useSettings( 'spacing.units' );
|
|
45
46
|
const units = useCustomUnits( {
|
|
46
|
-
availableUnits:
|
|
47
|
-
'px',
|
|
48
|
-
'em',
|
|
49
|
-
'rem',
|
|
50
|
-
'vw',
|
|
51
|
-
'vh',
|
|
52
|
-
],
|
|
47
|
+
availableUnits: availableUnits || [ 'px', 'em', 'rem', 'vw', 'vh' ],
|
|
53
48
|
defaultValues: { px: 430, '%': 20, em: 20, rem: 20, vw: 20, vh: 50 },
|
|
54
49
|
} );
|
|
55
50
|
|
package/src/file/index.php
CHANGED
|
@@ -59,7 +59,8 @@ function render_block_core_file( $attributes, $content, $block ) {
|
|
|
59
59
|
$processor->next_tag();
|
|
60
60
|
$processor->set_attribute( 'data-wp-interactive', '' );
|
|
61
61
|
$processor->next_tag( 'object' );
|
|
62
|
-
$processor->set_attribute( 'data-wp-
|
|
62
|
+
$processor->set_attribute( 'data-wp-bind--hidden', '!selectors.core.file.hasPdfPreview' );
|
|
63
|
+
$processor->set_attribute( 'hidden', true );
|
|
63
64
|
return $processor->get_updated_html();
|
|
64
65
|
}
|
|
65
66
|
|
package/src/file/style.scss
CHANGED
|
@@ -29,12 +29,6 @@
|
|
|
29
29
|
margin-bottom: 1em;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
@media (max-width: 768px) {
|
|
33
|
-
.wp-block-file__embed {
|
|
34
|
-
display: none;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
32
|
//This needs a low specificity so it won't override the rules from the button element if defined in theme.json.
|
|
39
33
|
:where(.wp-block-file__button) {
|
|
40
34
|
border-radius: 2em;
|
package/src/file/view.js
CHANGED
|
@@ -5,13 +5,13 @@ import { store } from '@wordpress/interactivity';
|
|
|
5
5
|
/**
|
|
6
6
|
* Internal dependencies
|
|
7
7
|
*/
|
|
8
|
-
import { browserSupportsPdfs } from './utils';
|
|
8
|
+
import { browserSupportsPdfs as hasPdfPreview } from './utils';
|
|
9
9
|
|
|
10
10
|
store( {
|
|
11
11
|
selectors: {
|
|
12
12
|
core: {
|
|
13
13
|
file: {
|
|
14
|
-
hasPdfPreview
|
|
14
|
+
hasPdfPreview,
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
},
|
package/src/form/edit.js
CHANGED
|
@@ -26,6 +26,8 @@ const ALLOWED_BLOCKS = [
|
|
|
26
26
|
'core/form-input',
|
|
27
27
|
'core/form-submit-button',
|
|
28
28
|
'core/form-submission-notification',
|
|
29
|
+
'core/group',
|
|
30
|
+
'core/columns',
|
|
29
31
|
];
|
|
30
32
|
|
|
31
33
|
const TEMPLATE = [
|
|
@@ -107,7 +109,7 @@ const Edit = ( { attributes, setAttributes, clientId } ) => {
|
|
|
107
109
|
help={
|
|
108
110
|
submissionMethod === 'custom'
|
|
109
111
|
? __(
|
|
110
|
-
'Select the method to use for form submissions. Additional options for the "custom" mode can be found in the "
|
|
112
|
+
'Select the method to use for form submissions. Additional options for the "custom" mode can be found in the "Advanced" section.'
|
|
111
113
|
)
|
|
112
114
|
: __(
|
|
113
115
|
'Select the method to use for form submissions.'
|
package/src/form/index.js
CHANGED
|
@@ -7,6 +7,11 @@ import metadata from './block.json';
|
|
|
7
7
|
import save from './save';
|
|
8
8
|
import variations from './variations';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* WordPress dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { addFilter } from '@wordpress/hooks';
|
|
14
|
+
|
|
10
15
|
const { name } = metadata;
|
|
11
16
|
|
|
12
17
|
export { metadata, name };
|
|
@@ -17,4 +22,36 @@ export const settings = {
|
|
|
17
22
|
variations,
|
|
18
23
|
};
|
|
19
24
|
|
|
20
|
-
export const init = () =>
|
|
25
|
+
export const init = () => {
|
|
26
|
+
// Prevent adding forms inside forms.
|
|
27
|
+
const DISALLOWED_PARENTS = [ 'core/form' ];
|
|
28
|
+
addFilter(
|
|
29
|
+
'blockEditor.__unstableCanInsertBlockType',
|
|
30
|
+
'removeTemplatePartsFromPostTemplates',
|
|
31
|
+
(
|
|
32
|
+
canInsert,
|
|
33
|
+
blockType,
|
|
34
|
+
rootClientId,
|
|
35
|
+
{ getBlock, getBlockParentsByBlockName }
|
|
36
|
+
) => {
|
|
37
|
+
if ( blockType.name !== 'core/form' ) {
|
|
38
|
+
return canInsert;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
for ( const disallowedParentType of DISALLOWED_PARENTS ) {
|
|
42
|
+
const hasDisallowedParent =
|
|
43
|
+
getBlock( rootClientId )?.name === disallowedParentType ||
|
|
44
|
+
getBlockParentsByBlockName(
|
|
45
|
+
rootClientId,
|
|
46
|
+
disallowedParentType
|
|
47
|
+
).length;
|
|
48
|
+
if ( hasDisallowedParent ) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return initBlock( { name, metadata, settings } );
|
|
57
|
+
};
|
package/src/form/variations.js
CHANGED
|
@@ -63,7 +63,7 @@ const variations = [
|
|
|
63
63
|
name: 'wp-privacy-form',
|
|
64
64
|
title: __( 'Experimental privacy request form' ),
|
|
65
65
|
keywords: [ 'GDPR' ],
|
|
66
|
-
description: __( 'A form
|
|
66
|
+
description: __( 'A form to request data exports and/or deletion.' ),
|
|
67
67
|
attributes: {
|
|
68
68
|
submissionMethod: 'custom',
|
|
69
69
|
action: '',
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
"apiVersion": 3,
|
|
4
4
|
"__experimental": true,
|
|
5
5
|
"name": "core/form-input",
|
|
6
|
-
"title": "Input
|
|
6
|
+
"title": "Input Field",
|
|
7
7
|
"category": "common",
|
|
8
|
-
"
|
|
8
|
+
"ancestor": [ "core/form" ],
|
|
9
9
|
"description": "The basic building block for forms.",
|
|
10
10
|
"keywords": [ "input", "form" ],
|
|
11
11
|
"textdomain": "default",
|
|
@@ -6,7 +6,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
6
6
|
const variations = [
|
|
7
7
|
{
|
|
8
8
|
name: 'text',
|
|
9
|
-
title: __( 'Text
|
|
9
|
+
title: __( 'Text Input' ),
|
|
10
10
|
icon: 'edit-page',
|
|
11
11
|
description: __( 'A generic text input.' ),
|
|
12
12
|
attributes: { type: 'text' },
|
|
@@ -17,7 +17,7 @@ const variations = [
|
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
name: 'textarea',
|
|
20
|
-
title: __( 'Textarea
|
|
20
|
+
title: __( 'Textarea Input' ),
|
|
21
21
|
icon: 'testimonial',
|
|
22
22
|
description: __(
|
|
23
23
|
'A textarea input to allow entering multiple lines of text.'
|
|
@@ -29,7 +29,7 @@ const variations = [
|
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
name: 'checkbox',
|
|
32
|
-
title: __( 'Checkbox
|
|
32
|
+
title: __( 'Checkbox Input' ),
|
|
33
33
|
description: __( 'A simple checkbox input.' ),
|
|
34
34
|
icon: 'forms',
|
|
35
35
|
attributes: { type: 'checkbox', inlineLabel: true },
|
|
@@ -39,7 +39,7 @@ const variations = [
|
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
name: 'email',
|
|
42
|
-
title: __( 'Email
|
|
42
|
+
title: __( 'Email Input' ),
|
|
43
43
|
icon: 'email',
|
|
44
44
|
description: __( 'Used for email addresses.' ),
|
|
45
45
|
attributes: { type: 'email' },
|
|
@@ -49,7 +49,7 @@ const variations = [
|
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
name: 'url',
|
|
52
|
-
title: __( 'URL
|
|
52
|
+
title: __( 'URL Input' ),
|
|
53
53
|
icon: 'admin-site',
|
|
54
54
|
description: __( 'Used for URLs.' ),
|
|
55
55
|
attributes: { type: 'url' },
|
|
@@ -59,7 +59,7 @@ const variations = [
|
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
name: 'tel',
|
|
62
|
-
title: __( 'Telephone
|
|
62
|
+
title: __( 'Telephone Input' ),
|
|
63
63
|
icon: 'phone',
|
|
64
64
|
description: __( 'Used for phone numbers.' ),
|
|
65
65
|
attributes: { type: 'tel' },
|
|
@@ -69,7 +69,7 @@ const variations = [
|
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
name: 'number',
|
|
72
|
-
title: __( 'Number
|
|
72
|
+
title: __( 'Number Input' ),
|
|
73
73
|
icon: 'edit-page',
|
|
74
74
|
description: __( 'A numeric input.' ),
|
|
75
75
|
attributes: { type: 'number' },
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"name": "core/form-submission-notification",
|
|
6
6
|
"title": "Form Submission Notification",
|
|
7
7
|
"category": "common",
|
|
8
|
-
"
|
|
8
|
+
"ancestor": [ "core/form" ],
|
|
9
9
|
"description": "Provide a notification message after the form has been submitted.",
|
|
10
10
|
"keywords": [ "form", "feedback", "notification", "message" ],
|
|
11
11
|
"textdomain": "default",
|
|
@@ -6,8 +6,8 @@ import { __ } from '@wordpress/i18n';
|
|
|
6
6
|
const variations = [
|
|
7
7
|
{
|
|
8
8
|
name: 'form-submission-success',
|
|
9
|
-
title: __( 'Form
|
|
10
|
-
description: __( 'Success message for form submissions' ),
|
|
9
|
+
title: __( 'Form Submission Success' ),
|
|
10
|
+
description: __( 'Success message for form submissions.' ),
|
|
11
11
|
attributes: {
|
|
12
12
|
type: 'success',
|
|
13
13
|
},
|
|
@@ -31,8 +31,8 @@ const variations = [
|
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
name: 'form-submission-error',
|
|
34
|
-
title: __( 'Form
|
|
35
|
-
description: __( 'Error/failure message for form submissions' ),
|
|
34
|
+
title: __( 'Form Submission Error' ),
|
|
35
|
+
description: __( 'Error/failure message for form submissions.' ),
|
|
36
36
|
attributes: {
|
|
37
37
|
type: 'error',
|
|
38
38
|
},
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"apiVersion": 3,
|
|
4
4
|
"__experimental": true,
|
|
5
5
|
"name": "core/form-submit-button",
|
|
6
|
-
"title": "Form
|
|
6
|
+
"title": "Form Submit Button",
|
|
7
7
|
"category": "common",
|
|
8
8
|
"icon": "button",
|
|
9
|
-
"
|
|
9
|
+
"ancestor": [ "core/form" ],
|
|
10
10
|
"description": "A submission button for forms.",
|
|
11
11
|
"keywords": [ "submit", "button", "form" ],
|
|
12
12
|
"textdomain": "default",
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
fireEvent,
|
|
6
|
+
getBlock,
|
|
7
|
+
getEditorHtml,
|
|
8
|
+
initializeEditor,
|
|
9
|
+
screen,
|
|
10
|
+
setupCoreBlocks,
|
|
11
|
+
within,
|
|
12
|
+
} from 'test/helpers';
|
|
13
|
+
|
|
14
|
+
const CLASSIC_BLOCK_HTML = `<p>I'm classic!</p>`;
|
|
15
|
+
const DEFAULT_EDITOR_CAPABILITIES = {
|
|
16
|
+
unsupportedBlockEditor: true,
|
|
17
|
+
canEnableUnsupportedBlockEditor: true,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
setupCoreBlocks();
|
|
21
|
+
|
|
22
|
+
describe( 'Classic block', () => {
|
|
23
|
+
it( 'displays option to edit using web editor', async () => {
|
|
24
|
+
await initializeEditor( {
|
|
25
|
+
initialHtml: CLASSIC_BLOCK_HTML,
|
|
26
|
+
capabilities: DEFAULT_EDITOR_CAPABILITIES,
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
const block = getBlock( screen, 'Classic' );
|
|
30
|
+
fireEvent.press( block );
|
|
31
|
+
|
|
32
|
+
// Tap the block to open the unsupported block details
|
|
33
|
+
fireEvent.press( within( block ).getByText( 'Unsupported' ) );
|
|
34
|
+
|
|
35
|
+
const actionButton = screen.getByText( 'Edit using web editor' );
|
|
36
|
+
expect( actionButton ).toBeVisible();
|
|
37
|
+
} );
|
|
38
|
+
|
|
39
|
+
it( 'converts content into blocks', async () => {
|
|
40
|
+
await initializeEditor( {
|
|
41
|
+
initialHtml: CLASSIC_BLOCK_HTML,
|
|
42
|
+
capabilities: DEFAULT_EDITOR_CAPABILITIES,
|
|
43
|
+
} );
|
|
44
|
+
|
|
45
|
+
const block = getBlock( screen, 'Classic' );
|
|
46
|
+
fireEvent.press( block );
|
|
47
|
+
|
|
48
|
+
// Tap the block to open the unsupported block details
|
|
49
|
+
fireEvent.press( within( block ).getByText( 'Unsupported' ) );
|
|
50
|
+
|
|
51
|
+
const actionButton = screen.getByText( 'Convert to blocks' );
|
|
52
|
+
expect( actionButton ).toBeVisible();
|
|
53
|
+
|
|
54
|
+
fireEvent.press( actionButton );
|
|
55
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
56
|
+
} );
|
|
57
|
+
} );
|
package/src/group/edit.js
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
useBlockProps,
|
|
8
8
|
InspectorControls,
|
|
9
9
|
useInnerBlocksProps,
|
|
10
|
-
useSetting,
|
|
11
10
|
store as blockEditorStore,
|
|
12
11
|
} from '@wordpress/block-editor';
|
|
13
12
|
import { SelectControl } from '@wordpress/components';
|
|
@@ -98,11 +97,7 @@ function GroupEdit( {
|
|
|
98
97
|
} = attributes;
|
|
99
98
|
|
|
100
99
|
// Layout settings.
|
|
101
|
-
const
|
|
102
|
-
const usedLayout = ! layout?.type
|
|
103
|
-
? { ...defaultLayout, ...layout, type: 'default' }
|
|
104
|
-
: { ...defaultLayout, ...layout };
|
|
105
|
-
const { type = 'default' } = usedLayout;
|
|
100
|
+
const { type = 'default' } = layout;
|
|
106
101
|
const layoutSupportEnabled =
|
|
107
102
|
themeSupportsLayout || type === 'flex' || type === 'grid';
|
|
108
103
|
|
|
@@ -112,7 +107,7 @@ function GroupEdit( {
|
|
|
112
107
|
} );
|
|
113
108
|
const [ showPlaceholder, setShowPlaceholder ] = useShouldShowPlaceHolder( {
|
|
114
109
|
attributes,
|
|
115
|
-
usedLayoutType:
|
|
110
|
+
usedLayoutType: type,
|
|
116
111
|
hasInnerBlocks,
|
|
117
112
|
} );
|
|
118
113
|
|
package/src/html/preview.js
CHANGED
|
@@ -22,12 +22,17 @@ const DEFAULT_STYLES = `
|
|
|
22
22
|
`;
|
|
23
23
|
|
|
24
24
|
export default function HTMLEditPreview( { content, isSelected } ) {
|
|
25
|
-
const settingStyles = useSelect(
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const settingStyles = useSelect(
|
|
26
|
+
( select ) => select( blockEditorStore ).getSettings().styles
|
|
27
|
+
);
|
|
28
28
|
|
|
29
29
|
const styles = useMemo(
|
|
30
|
-
() => [
|
|
30
|
+
() => [
|
|
31
|
+
DEFAULT_STYLES,
|
|
32
|
+
...transformStyles(
|
|
33
|
+
settingStyles.filter( ( style ) => style.css )
|
|
34
|
+
),
|
|
35
|
+
],
|
|
31
36
|
[ settingStyles ]
|
|
32
37
|
);
|
|
33
38
|
|
package/src/image/image.js
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
__experimentalImageURLInputUI as ImageURLInputUI,
|
|
25
25
|
MediaReplaceFlow,
|
|
26
26
|
store as blockEditorStore,
|
|
27
|
-
|
|
27
|
+
useSettings,
|
|
28
28
|
BlockAlignmentControl,
|
|
29
29
|
__experimentalImageEditor as ImageEditor,
|
|
30
30
|
__experimentalGetElementClassName,
|
|
@@ -83,6 +83,11 @@ const scaleOptions = [
|
|
|
83
83
|
},
|
|
84
84
|
];
|
|
85
85
|
|
|
86
|
+
const disabledClickProps = {
|
|
87
|
+
onClick: ( event ) => event.preventDefault(),
|
|
88
|
+
'aria-disabled': true,
|
|
89
|
+
};
|
|
90
|
+
|
|
86
91
|
export default function Image( {
|
|
87
92
|
temporaryURL,
|
|
88
93
|
attributes,
|
|
@@ -369,7 +374,7 @@ export default function Image( {
|
|
|
369
374
|
availableUnits: [ 'px' ],
|
|
370
375
|
} );
|
|
371
376
|
|
|
372
|
-
const lightboxSetting =
|
|
377
|
+
const [ lightboxSetting ] = useSettings( 'lightbox' );
|
|
373
378
|
|
|
374
379
|
const showLightboxToggle =
|
|
375
380
|
!! lightbox || lightboxSetting?.allowEditing === true;
|
|
@@ -543,14 +548,14 @@ export default function Image( {
|
|
|
543
548
|
{ showLightboxToggle && (
|
|
544
549
|
<ToolsPanelItem
|
|
545
550
|
hasValue={ () => !! lightbox }
|
|
546
|
-
label={ __( 'Expand on
|
|
551
|
+
label={ __( 'Expand on click' ) }
|
|
547
552
|
onDeselect={ () => {
|
|
548
553
|
setAttributes( { lightbox: undefined } );
|
|
549
554
|
} }
|
|
550
555
|
isShownByDefault={ true }
|
|
551
556
|
>
|
|
552
557
|
<ToggleControl
|
|
553
|
-
label={ __( 'Expand on
|
|
558
|
+
label={ __( 'Expand on click' ) }
|
|
554
559
|
checked={ lightboxChecked }
|
|
555
560
|
onChange={ ( newValue ) => {
|
|
556
561
|
setAttributes( {
|
|
@@ -725,7 +730,6 @@ export default function Image( {
|
|
|
725
730
|
}
|
|
726
731
|
}
|
|
727
732
|
/* eslint-enable no-lonely-if */
|
|
728
|
-
|
|
729
733
|
img = (
|
|
730
734
|
<ResizableBox
|
|
731
735
|
style={ {
|
|
@@ -784,7 +788,14 @@ export default function Image( {
|
|
|
784
788
|
{ /* Hide controls during upload to avoid component remount,
|
|
785
789
|
which causes duplicated image upload. */ }
|
|
786
790
|
{ ! temporaryURL && controls }
|
|
787
|
-
{
|
|
791
|
+
{ /* If the image has a href, wrap in an <a /> tag to trigger any inherited link element styles */ }
|
|
792
|
+
{ !! href ? (
|
|
793
|
+
<a href={ href } { ...disabledClickProps }>
|
|
794
|
+
{ img }
|
|
795
|
+
</a>
|
|
796
|
+
) : (
|
|
797
|
+
img
|
|
798
|
+
) }
|
|
788
799
|
{ showCaption &&
|
|
789
800
|
( ! RichText.isEmpty( caption ) || isSelected ) && (
|
|
790
801
|
<RichText
|