@wordpress/block-library 7.9.0 → 7.10.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/comment-template/index.js +1 -1
- package/build/comments/deprecated.js +65 -0
- package/build/comments/deprecated.js.map +1 -0
- package/build/comments/index.js +5 -2
- package/build/comments/index.js.map +1 -1
- package/build/comments-pagination/index.js +1 -1
- package/build/comments-title/deprecated.js +1 -1
- package/build/comments-title/index.js +1 -1
- package/build/cover/edit/block-controls.js +2 -12
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/cover/edit/cover-placeholder.js +3 -1
- package/build/cover/edit/cover-placeholder.js.map +1 -1
- package/build/cover/edit/index.js +19 -4
- package/build/cover/edit/index.js.map +1 -1
- package/build/gallery/edit.js +9 -17
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/transforms.js +30 -20
- package/build/gallery/transforms.js.map +1 -1
- package/build/gallery/use-get-media.js +7 -18
- package/build/gallery/use-get-media.js.map +1 -1
- package/build/group/edit.js +1 -3
- package/build/group/edit.js.map +1 -1
- package/build/heading/heading-level-dropdown.js +2 -1
- package/build/heading/heading-level-dropdown.js.map +1 -1
- package/build/heading/index.js +9 -4
- package/build/heading/index.js.map +1 -1
- package/build/latest-posts/edit.js +1 -1
- package/build/latest-posts/edit.js.map +1 -1
- package/build/more/edit.js +2 -4
- package/build/more/edit.js.map +1 -1
- package/build/navigation/view.js +7 -4
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/hooks.js +0 -16
- package/build/navigation-link/hooks.js.map +1 -1
- package/build/navigation-link/index.js +1 -1
- package/build/navigation-link/index.js.map +1 -1
- package/build/navigation-submenu/view.js +7 -4
- package/build/navigation-submenu/view.js.map +1 -1
- package/build/nextpage/edit.js +1 -3
- package/build/nextpage/edit.js.map +1 -1
- package/build/page-list/edit.js +2 -2
- package/build/page-list/edit.js.map +1 -1
- package/build/post-comments-form/edit.js +2 -4
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-terms/index.js +1 -1
- package/build/post-terms/index.js.map +1 -1
- package/build/post-title/index.js +1 -0
- package/build/post-title/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +1 -1
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/index.js +1 -1
- package/build/query/index.js.map +1 -1
- package/build/site-logo/edit.js +5 -13
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-title/edit/level-toolbar.js +2 -1
- package/build/site-title/edit/level-toolbar.js.map +1 -1
- package/build/template-part/index.js +1 -1
- package/build/template-part/index.js.map +1 -1
- package/build/template-part/variations.js +0 -16
- package/build/template-part/variations.js.map +1 -1
- package/build/utils/clean-empty-object.js +5 -3
- package/build/utils/clean-empty-object.js.map +1 -1
- package/build/video/tracks-editor.js +9 -11
- package/build/video/tracks-editor.js.map +1 -1
- package/build-module/comment-template/index.js +1 -1
- package/build-module/comments/deprecated.js +54 -0
- package/build-module/comments/deprecated.js.map +1 -0
- package/build-module/comments/index.js +4 -2
- package/build-module/comments/index.js.map +1 -1
- package/build-module/comments-pagination/index.js +1 -1
- package/build-module/comments-title/deprecated.js +1 -1
- package/build-module/comments-title/index.js +1 -1
- package/build-module/cover/edit/block-controls.js +3 -13
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/cover/edit/cover-placeholder.js +3 -1
- package/build-module/cover/edit/cover-placeholder.js.map +1 -1
- package/build-module/cover/edit/index.js +19 -4
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/gallery/edit.js +9 -16
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/transforms.js +30 -20
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/gallery/use-get-media.js +6 -16
- package/build-module/gallery/use-get-media.js.map +1 -1
- package/build-module/group/edit.js +1 -3
- package/build-module/group/edit.js.map +1 -1
- package/build-module/heading/heading-level-dropdown.js +2 -1
- package/build-module/heading/heading-level-dropdown.js.map +1 -1
- package/build-module/heading/index.js +9 -4
- package/build-module/heading/index.js.map +1 -1
- package/build-module/latest-posts/edit.js +2 -2
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/more/edit.js +2 -4
- package/build-module/more/edit.js.map +1 -1
- package/build-module/navigation/view.js +7 -4
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/hooks.js +0 -13
- package/build-module/navigation-link/hooks.js.map +1 -1
- package/build-module/navigation-link/index.js +1 -1
- package/build-module/navigation-link/index.js.map +1 -1
- package/build-module/navigation-submenu/view.js +7 -4
- package/build-module/navigation-submenu/view.js.map +1 -1
- package/build-module/nextpage/edit.js +1 -3
- package/build-module/nextpage/edit.js.map +1 -1
- package/build-module/page-list/edit.js +2 -2
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/post-comments-form/edit.js +2 -4
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-terms/index.js +1 -1
- package/build-module/post-terms/index.js.map +1 -1
- package/build-module/post-title/index.js +1 -0
- package/build-module/post-title/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +1 -1
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/index.js +1 -1
- package/build-module/query/index.js.map +1 -1
- package/build-module/site-logo/edit.js +5 -13
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-title/edit/level-toolbar.js +2 -1
- package/build-module/site-title/edit/level-toolbar.js.map +1 -1
- package/build-module/template-part/index.js +1 -1
- package/build-module/template-part/index.js.map +1 -1
- package/build-module/template-part/variations.js +0 -13
- package/build-module/template-part/variations.js.map +1 -1
- package/build-module/utils/clean-empty-object.js +5 -2
- package/build-module/utils/clean-empty-object.js.map +1 -1
- package/build-module/video/tracks-editor.js +9 -11
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/comment-template/style-rtl.css +12 -0
- package/build-style/comment-template/style.css +12 -0
- package/build-style/editor-rtl.css +1 -1
- package/build-style/editor.css +1 -1
- package/build-style/elements-rtl.css +82 -0
- package/build-style/elements.css +82 -0
- package/build-style/query/editor-rtl.css +1 -1
- package/build-style/query/editor.css +1 -1
- package/build-style/search/theme-rtl.css +5 -0
- package/build-style/search/theme.css +5 -0
- package/build-style/style-rtl.css +19 -0
- package/build-style/style.css +19 -0
- package/build-style/theme-rtl.css +5 -0
- package/build-style/theme.css +5 -0
- package/package.json +28 -28
- package/src/comment-template/block.json +1 -1
- package/src/comment-template/style.scss +14 -0
- package/src/comments/block.json +1 -1
- package/src/comments/deprecated.js +53 -0
- package/src/comments/index.js +2 -0
- package/src/comments-pagination/block.json +1 -1
- package/src/comments-title/block.json +1 -1
- package/src/cover/edit/block-controls.js +4 -20
- package/src/cover/edit/cover-placeholder.js +2 -0
- package/src/cover/edit/index.js +16 -0
- package/src/elements.scss +6 -0
- package/src/gallery/edit.js +8 -21
- package/src/gallery/index.php +1 -1
- package/src/gallery/transforms.js +25 -10
- package/src/gallery/use-get-media.js +11 -28
- package/src/group/edit.js +1 -3
- package/src/heading/heading-level-dropdown.js +1 -0
- package/src/heading/index.js +8 -2
- package/src/latest-posts/edit.js +2 -6
- package/src/more/edit.js +9 -11
- package/src/navigation/style.scss +1 -1
- package/src/navigation/view.js +6 -6
- package/src/navigation-link/hooks.js +0 -14
- package/src/navigation-link/index.js +1 -1
- package/src/navigation-link/test/__snapshots__/hooks.js.snap +0 -93
- package/src/navigation-link/test/hooks.js +0 -12
- package/src/navigation-submenu/view.js +6 -6
- package/src/nextpage/edit.js +1 -3
- package/src/page-list/edit.js +3 -5
- package/src/post-comments-form/edit.js +4 -7
- package/src/post-template/index.php +8 -14
- package/src/post-terms/index.js +1 -1
- package/src/post-title/block.json +1 -0
- package/src/query/edit/inspector-controls/index.js +1 -1
- package/src/query/editor.scss +1 -1
- package/src/query/index.js +1 -1
- package/src/query-no-results/index.php +10 -8
- package/src/search/theme.scss +5 -0
- package/src/site-logo/edit.js +2 -11
- package/src/site-title/edit/level-toolbar.js +1 -0
- package/src/social-link/index.php +16 -0
- package/src/style.scss +1 -0
- package/src/template-part/index.js +1 -1
- package/src/template-part/variations.js +0 -11
- package/src/utils/clean-empty-object.js +8 -2
- package/src/video/tracks-editor.js +1 -1
- package/build/gallery/use-short-code-transform.js +0 -64
- package/build/gallery/use-short-code-transform.js.map +0 -1
- package/build/navigation-link/fallback-variations.js +0 -75
- package/build/navigation-link/fallback-variations.js.map +0 -1
- package/build/template-part/fallback-variations.js +0 -59
- package/build/template-part/fallback-variations.js.map +0 -1
- package/build-module/gallery/use-short-code-transform.js +0 -54
- package/build-module/gallery/use-short-code-transform.js.map +0 -1
- package/build-module/navigation-link/fallback-variations.js +0 -65
- package/build-module/navigation-link/fallback-variations.js.map +0 -1
- package/build-module/template-part/fallback-variations.js +0 -47
- package/build-module/template-part/fallback-variations.js.map +0 -1
- package/src/gallery/use-short-code-transform.js +0 -55
- package/src/navigation-link/fallback-variations.js +0 -65
- package/src/template-part/fallback-variations.js +0 -51
|
@@ -14,22 +14,17 @@ import { __ } from '@wordpress/i18n';
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
|
-
import { ALLOWED_MEDIA_TYPES
|
|
17
|
+
import { ALLOWED_MEDIA_TYPES } from '../shared';
|
|
18
18
|
|
|
19
19
|
export default function CoverBlockControls( {
|
|
20
20
|
attributes,
|
|
21
21
|
setAttributes,
|
|
22
22
|
onSelectMedia,
|
|
23
23
|
currentSettings,
|
|
24
|
+
toggleUseFeaturedImage,
|
|
24
25
|
} ) {
|
|
25
|
-
const {
|
|
26
|
-
|
|
27
|
-
id,
|
|
28
|
-
useFeaturedImage,
|
|
29
|
-
dimRatio,
|
|
30
|
-
minHeight,
|
|
31
|
-
minHeightUnit,
|
|
32
|
-
} = attributes;
|
|
26
|
+
const { contentPosition, id, useFeaturedImage, minHeight, minHeightUnit } =
|
|
27
|
+
attributes;
|
|
33
28
|
const { hasInnerBlocks, url } = currentSettings;
|
|
34
29
|
|
|
35
30
|
const [ prevMinHeightValue, setPrevMinHeightValue ] = useState( minHeight );
|
|
@@ -63,17 +58,6 @@ export default function CoverBlockControls( {
|
|
|
63
58
|
} );
|
|
64
59
|
};
|
|
65
60
|
|
|
66
|
-
const toggleUseFeaturedImage = () => {
|
|
67
|
-
setAttributes( {
|
|
68
|
-
id: undefined,
|
|
69
|
-
url: undefined,
|
|
70
|
-
useFeaturedImage: ! useFeaturedImage,
|
|
71
|
-
dimRatio: dimRatio === 100 ? 50 : dimRatio,
|
|
72
|
-
backgroundType: useFeaturedImage
|
|
73
|
-
? IMAGE_BACKGROUND_TYPE
|
|
74
|
-
: undefined,
|
|
75
|
-
} );
|
|
76
|
-
};
|
|
77
61
|
return (
|
|
78
62
|
<>
|
|
79
63
|
<BlockControls group="block">
|
|
@@ -16,6 +16,7 @@ export default function CoverPlaceholder( {
|
|
|
16
16
|
onSelectMedia,
|
|
17
17
|
onError,
|
|
18
18
|
style,
|
|
19
|
+
toggleUseFeaturedImage,
|
|
19
20
|
} ) {
|
|
20
21
|
return (
|
|
21
22
|
<MediaPlaceholder
|
|
@@ -30,6 +31,7 @@ export default function CoverPlaceholder( {
|
|
|
30
31
|
accept="image/*,video/*"
|
|
31
32
|
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
32
33
|
disableMediaButtons={ disableMediaButtons }
|
|
34
|
+
onToggleFeaturedImage={ toggleUseFeaturedImage }
|
|
33
35
|
onError={ onError }
|
|
34
36
|
style={ style }
|
|
35
37
|
>
|
package/src/cover/edit/index.js
CHANGED
|
@@ -211,12 +211,25 @@ function CoverEdit( {
|
|
|
211
211
|
overlayColor,
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
+
const toggleUseFeaturedImage = () => {
|
|
215
|
+
setAttributes( {
|
|
216
|
+
id: undefined,
|
|
217
|
+
url: undefined,
|
|
218
|
+
useFeaturedImage: ! useFeaturedImage,
|
|
219
|
+
dimRatio: dimRatio === 100 ? 50 : dimRatio,
|
|
220
|
+
backgroundType: useFeaturedImage
|
|
221
|
+
? IMAGE_BACKGROUND_TYPE
|
|
222
|
+
: undefined,
|
|
223
|
+
} );
|
|
224
|
+
};
|
|
225
|
+
|
|
214
226
|
const blockControls = (
|
|
215
227
|
<CoverBlockControls
|
|
216
228
|
attributes={ attributes }
|
|
217
229
|
setAttributes={ setAttributes }
|
|
218
230
|
onSelectMedia={ onSelectMedia }
|
|
219
231
|
currentSettings={ currentSettings }
|
|
232
|
+
toggleUseFeaturedImage={ toggleUseFeaturedImage }
|
|
220
233
|
/>
|
|
221
234
|
);
|
|
222
235
|
|
|
@@ -228,6 +241,7 @@ function CoverEdit( {
|
|
|
228
241
|
setOverlayColor={ setOverlayColor }
|
|
229
242
|
coverRef={ ref }
|
|
230
243
|
currentSettings={ currentSettings }
|
|
244
|
+
toggleUseFeaturedImage={ toggleUseFeaturedImage }
|
|
231
245
|
/>
|
|
232
246
|
);
|
|
233
247
|
|
|
@@ -249,6 +263,7 @@ function CoverEdit( {
|
|
|
249
263
|
style={ {
|
|
250
264
|
minHeight: minHeightWithUnit || undefined,
|
|
251
265
|
} }
|
|
266
|
+
toggleUseFeaturedImage={ toggleUseFeaturedImage }
|
|
252
267
|
>
|
|
253
268
|
<div className="wp-block-cover__placeholder-background-options">
|
|
254
269
|
<ColorPalette
|
|
@@ -384,6 +399,7 @@ function CoverEdit( {
|
|
|
384
399
|
disableMediaButtons
|
|
385
400
|
onSelectMedia={ onSelectMedia }
|
|
386
401
|
onError={ onUploadError }
|
|
402
|
+
toggleUseFeaturedImage={ toggleUseFeaturedImage }
|
|
387
403
|
/>
|
|
388
404
|
<div { ...innerBlocksProps } />
|
|
389
405
|
</div>
|
package/src/gallery/edit.js
CHANGED
|
@@ -51,7 +51,6 @@ import {
|
|
|
51
51
|
LINK_DESTINATION_NONE,
|
|
52
52
|
} from './constants';
|
|
53
53
|
import useImageSizes from './use-image-sizes';
|
|
54
|
-
import useShortCodeTransform from './use-short-code-transform';
|
|
55
54
|
import useGetNewImages from './use-get-new-images';
|
|
56
55
|
import useGetMedia from './use-get-media';
|
|
57
56
|
import GapStyles from './gap-styles';
|
|
@@ -87,14 +86,7 @@ function GalleryEdit( props ) {
|
|
|
87
86
|
insertBlocksAfter,
|
|
88
87
|
} = props;
|
|
89
88
|
|
|
90
|
-
const {
|
|
91
|
-
columns,
|
|
92
|
-
imageCrop,
|
|
93
|
-
linkTarget,
|
|
94
|
-
linkTo,
|
|
95
|
-
shortCodeTransforms,
|
|
96
|
-
sizeSlug,
|
|
97
|
-
} = attributes;
|
|
89
|
+
const { columns, imageCrop, linkTarget, linkTo, sizeSlug } = attributes;
|
|
98
90
|
|
|
99
91
|
const {
|
|
100
92
|
__unstableMarkNextChangeAsNotPersistent,
|
|
@@ -151,6 +143,8 @@ function GalleryEdit( props ) {
|
|
|
151
143
|
|
|
152
144
|
useEffect( () => {
|
|
153
145
|
newImages?.forEach( ( newImage ) => {
|
|
146
|
+
// Update the images data without creating new undo levels.
|
|
147
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
154
148
|
updateBlockAttributes( newImage.clientId, {
|
|
155
149
|
...buildImageAttributes( newImage.attributes ),
|
|
156
150
|
id: newImage.id,
|
|
@@ -162,16 +156,6 @@ function GalleryEdit( props ) {
|
|
|
162
156
|
}
|
|
163
157
|
}, [ newImages ] );
|
|
164
158
|
|
|
165
|
-
const shortCodeImages = useShortCodeTransform( shortCodeTransforms );
|
|
166
|
-
|
|
167
|
-
useEffect( () => {
|
|
168
|
-
if ( ! shortCodeTransforms || ! shortCodeImages ) {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
updateImages( shortCodeImages );
|
|
172
|
-
setAttributes( { shortCodeTransforms: undefined } );
|
|
173
|
-
}, [ shortCodeTransforms, shortCodeImages ] );
|
|
174
|
-
|
|
175
159
|
const imageSizeOptions = useImageSizes(
|
|
176
160
|
imageData,
|
|
177
161
|
isSelected,
|
|
@@ -208,8 +192,9 @@ function GalleryEdit( props ) {
|
|
|
208
192
|
...getHrefAndDestination( image, linkTo ),
|
|
209
193
|
...getUpdatedLinkTargetSettings( linkTarget, attributes ),
|
|
210
194
|
className: newClassName,
|
|
211
|
-
caption: imageAttributes.caption,
|
|
212
195
|
sizeSlug,
|
|
196
|
+
caption: imageAttributes.caption || image.caption?.raw,
|
|
197
|
+
alt: imageAttributes.alt || image.alt_text,
|
|
213
198
|
};
|
|
214
199
|
}
|
|
215
200
|
|
|
@@ -547,7 +532,9 @@ function GalleryEdit( props ) {
|
|
|
547
532
|
onSelect={ updateImages }
|
|
548
533
|
name={ __( 'Add' ) }
|
|
549
534
|
multiple={ true }
|
|
550
|
-
mediaIds={ images
|
|
535
|
+
mediaIds={ images
|
|
536
|
+
.filter( ( image ) => image.id )
|
|
537
|
+
.map( ( image ) => image.id ) }
|
|
551
538
|
addToGallery={ hasImageIds }
|
|
552
539
|
/>
|
|
553
540
|
</BlockControls>
|
package/src/gallery/index.php
CHANGED
|
@@ -81,7 +81,7 @@ function block_core_gallery_render( $attributes, $content ) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
// Set the CSS variable to the column value, and the `gap` property to the combined gap value.
|
|
84
|
-
$style = '.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_column . '; gap: ' . $gap_value . '}';
|
|
84
|
+
$style = '.wp-block-gallery.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_column . '; gap: ' . $gap_value . '}';
|
|
85
85
|
|
|
86
86
|
gutenberg_enqueue_block_support_styles( $style, 11 );
|
|
87
87
|
return $content;
|
|
@@ -195,16 +195,6 @@ const transforms = {
|
|
|
195
195
|
}
|
|
196
196
|
},
|
|
197
197
|
},
|
|
198
|
-
shortCodeTransforms: {
|
|
199
|
-
type: 'array',
|
|
200
|
-
shortcode: ( { named: { ids } } ) => {
|
|
201
|
-
if ( isGalleryV2Enabled() ) {
|
|
202
|
-
return parseShortcodeIds( ids ).map( ( id ) => ( {
|
|
203
|
-
id: parseInt( id ),
|
|
204
|
-
} ) );
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
198
|
columns: {
|
|
209
199
|
type: 'number',
|
|
210
200
|
shortcode: ( { named: { columns = '3' } } ) => {
|
|
@@ -235,6 +225,31 @@ const transforms = {
|
|
|
235
225
|
},
|
|
236
226
|
},
|
|
237
227
|
},
|
|
228
|
+
transform( { named: { ids, columns = 3, link } } ) {
|
|
229
|
+
const imageIds = parseShortcodeIds( ids ).map( ( id ) =>
|
|
230
|
+
parseInt( id, 10 )
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
let linkTo = LINK_DESTINATION_NONE;
|
|
234
|
+
if ( link === 'post' ) {
|
|
235
|
+
linkTo = LINK_DESTINATION_ATTACHMENT;
|
|
236
|
+
} else if ( link === 'file' ) {
|
|
237
|
+
linkTo = LINK_DESTINATION_MEDIA;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const galleryBlock = createBlock(
|
|
241
|
+
'core/gallery',
|
|
242
|
+
{
|
|
243
|
+
columns: parseInt( columns, 10 ),
|
|
244
|
+
linkTo,
|
|
245
|
+
},
|
|
246
|
+
imageIds.map( ( imageId ) =>
|
|
247
|
+
createBlock( 'core/image', { id: imageId } )
|
|
248
|
+
)
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
return galleryBlock;
|
|
252
|
+
},
|
|
238
253
|
isMatch( { named } ) {
|
|
239
254
|
return undefined !== named.ids;
|
|
240
255
|
},
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useState } from '@wordpress/element';
|
|
5
4
|
import { useSelect } from '@wordpress/data';
|
|
6
5
|
import { store as coreStore } from '@wordpress/core-data';
|
|
7
6
|
|
|
7
|
+
const EMPTY_IMAGE_MEDIA = [];
|
|
8
|
+
|
|
8
9
|
/**
|
|
9
10
|
* Retrieves the extended media info for each gallery image from the store. This is used to
|
|
10
11
|
* determine which image size options are available for the current gallery.
|
|
@@ -14,42 +15,24 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
14
15
|
* @return {Array} An array of media info options for each gallery image.
|
|
15
16
|
*/
|
|
16
17
|
export default function useGetMedia( innerBlockImages ) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const imageMedia = useSelect(
|
|
18
|
+
return useSelect(
|
|
20
19
|
( select ) => {
|
|
21
|
-
if ( ! innerBlockImages?.length ) {
|
|
22
|
-
return currentImageMedia;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
20
|
const imageIds = innerBlockImages
|
|
26
21
|
.map( ( imageBlock ) => imageBlock.attributes.id )
|
|
27
22
|
.filter( ( id ) => id !== undefined );
|
|
28
23
|
|
|
29
24
|
if ( imageIds.length === 0 ) {
|
|
30
|
-
return
|
|
25
|
+
return EMPTY_IMAGE_MEDIA;
|
|
31
26
|
}
|
|
32
27
|
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
return (
|
|
29
|
+
select( coreStore ).getMediaItems( {
|
|
30
|
+
include: imageIds.join( ',' ),
|
|
31
|
+
per_page: imageIds.length,
|
|
32
|
+
orderby: 'include',
|
|
33
|
+
} ) ?? EMPTY_IMAGE_MEDIA
|
|
34
|
+
);
|
|
38
35
|
},
|
|
39
36
|
[ innerBlockImages ]
|
|
40
37
|
);
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
imageMedia?.length !== currentImageMedia?.length ||
|
|
44
|
-
imageMedia?.some(
|
|
45
|
-
( newImage ) =>
|
|
46
|
-
! currentImageMedia.find(
|
|
47
|
-
( currentImage ) => currentImage.id === newImage.id
|
|
48
|
-
)
|
|
49
|
-
)
|
|
50
|
-
) {
|
|
51
|
-
setCurrentImageMedia( imageMedia );
|
|
52
|
-
return imageMedia;
|
|
53
|
-
}
|
|
54
|
-
return currentImageMedia;
|
|
55
38
|
}
|
package/src/group/edit.js
CHANGED
|
@@ -52,9 +52,7 @@ function GroupEdit( { attributes, setAttributes, clientId } ) {
|
|
|
52
52
|
const { type = 'default' } = usedLayout;
|
|
53
53
|
const layoutSupportEnabled = themeSupportsLayout || type !== 'default';
|
|
54
54
|
|
|
55
|
-
const blockProps = useBlockProps(
|
|
56
|
-
className: `is-layout-${ type }`,
|
|
57
|
-
} );
|
|
55
|
+
const blockProps = useBlockProps();
|
|
58
56
|
|
|
59
57
|
const innerBlocksProps = useInnerBlocksProps(
|
|
60
58
|
layoutSupportEnabled
|
package/src/heading/index.js
CHANGED
|
@@ -31,9 +31,15 @@ export const settings = {
|
|
|
31
31
|
},
|
|
32
32
|
},
|
|
33
33
|
__experimentalLabel( attributes, { context } ) {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const { content, level } = attributes;
|
|
35
|
+
|
|
36
|
+
// In the list view, use the block's content as the label.
|
|
37
|
+
// If the content is empty, fall back to the default label.
|
|
38
|
+
if ( context === 'list-view' && content ) {
|
|
39
|
+
return content;
|
|
40
|
+
}
|
|
36
41
|
|
|
42
|
+
if ( context === 'accessibility' ) {
|
|
37
43
|
return isEmpty( content )
|
|
38
44
|
? sprintf(
|
|
39
45
|
/* translators: accessibility text. %s: heading level. */
|
package/src/latest-posts/edit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { get, includes,
|
|
4
|
+
import { get, includes, pickBy } from 'lodash';
|
|
5
5
|
import classnames from 'classnames';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -432,11 +432,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
|
|
|
432
432
|
</BlockControls>
|
|
433
433
|
<ul { ...blockProps }>
|
|
434
434
|
{ displayPosts.map( ( post, i ) => {
|
|
435
|
-
const titleTrimmed =
|
|
436
|
-
'title',
|
|
437
|
-
'rendered',
|
|
438
|
-
'trim',
|
|
439
|
-
] );
|
|
435
|
+
const titleTrimmed = post.title.rendered.trim();
|
|
440
436
|
let excerpt = post.excerpt.rendered;
|
|
441
437
|
const currentAuthor = authorList?.find(
|
|
442
438
|
( author ) => author.id === post.author
|
package/src/more/edit.js
CHANGED
|
@@ -53,17 +53,15 @@ export default function MoreEdit( {
|
|
|
53
53
|
</PanelBody>
|
|
54
54
|
</InspectorControls>
|
|
55
55
|
<div { ...useBlockProps() }>
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
/>
|
|
66
|
-
</div>
|
|
56
|
+
<input
|
|
57
|
+
aria-label={ __( 'Read more link text' ) }
|
|
58
|
+
type="text"
|
|
59
|
+
value={ customText }
|
|
60
|
+
placeholder={ DEFAULT_TEXT }
|
|
61
|
+
onChange={ onChangeInput }
|
|
62
|
+
onKeyDown={ onKeyDown }
|
|
63
|
+
style={ style }
|
|
64
|
+
/>
|
|
67
65
|
</div>
|
|
68
66
|
</>
|
|
69
67
|
);
|
package/src/navigation/view.js
CHANGED
|
@@ -4,8 +4,6 @@ function closeSubmenus( element ) {
|
|
|
4
4
|
.querySelectorAll( '[aria-expanded="true"]' )
|
|
5
5
|
.forEach( function ( toggle ) {
|
|
6
6
|
toggle.setAttribute( 'aria-expanded', 'false' );
|
|
7
|
-
// Always focus the trigger, this becomes especially useful in closing submenus with escape key to ensure focus doesn't get trapped.
|
|
8
|
-
toggle.focus();
|
|
9
7
|
} );
|
|
10
8
|
}
|
|
11
9
|
|
|
@@ -63,11 +61,13 @@ window.addEventListener( 'load', () => {
|
|
|
63
61
|
'.wp-block-navigation-item.has-child'
|
|
64
62
|
);
|
|
65
63
|
submenuBlocks.forEach( function ( block ) {
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
if ( ! block.contains( event.target ) ) {
|
|
65
|
+
closeSubmenus( block );
|
|
66
|
+
} else if ( event.key === 'Escape' ) {
|
|
67
|
+
const toggle = block.querySelector( '[aria-expanded="true"]' );
|
|
70
68
|
closeSubmenus( block );
|
|
69
|
+
// Focus the submenu trigger so focus does not get trapped in the closed submenu.
|
|
70
|
+
toggle?.focus();
|
|
71
71
|
}
|
|
72
72
|
} );
|
|
73
73
|
} );
|
|
@@ -9,11 +9,6 @@ import {
|
|
|
9
9
|
customPostType,
|
|
10
10
|
} from '@wordpress/icons';
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import fallbackVariations from './fallback-variations';
|
|
16
|
-
|
|
17
12
|
function getIcon( variationName ) {
|
|
18
13
|
switch ( variationName ) {
|
|
19
14
|
case 'post':
|
|
@@ -34,15 +29,6 @@ export function enhanceNavigationLinkVariations( settings, name ) {
|
|
|
34
29
|
return settings;
|
|
35
30
|
}
|
|
36
31
|
|
|
37
|
-
// Fallback handling may be deleted after supported WP ranges understand the `variations`
|
|
38
|
-
// property when passed to register_block_type in index.php.
|
|
39
|
-
if ( ! settings.variations ) {
|
|
40
|
-
return {
|
|
41
|
-
...settings,
|
|
42
|
-
variations: fallbackVariations,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
32
|
// Otherwise decorate server passed variations with an icon and isActive function.
|
|
47
33
|
if ( settings.variations ) {
|
|
48
34
|
const isActive = ( blockAttributes, variationAttributes ) => {
|
|
@@ -88,7 +88,7 @@ export const settings = {
|
|
|
88
88
|
transforms,
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
// importing this file includes side effects. This is
|
|
91
|
+
// importing this file includes side effects. This is added in block-library/package.json under sideEffects
|
|
92
92
|
addFilter(
|
|
93
93
|
'blocks.registerBlockType',
|
|
94
94
|
'core/navigation-link',
|
|
@@ -1,98 +1,5 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`hooks enhanceNavigationLinkVariations adds fallback variations when variations are missing 1`] = `
|
|
4
|
-
Object {
|
|
5
|
-
"name": "core/navigation-link",
|
|
6
|
-
"one": "one",
|
|
7
|
-
"three": "three",
|
|
8
|
-
"two": "two",
|
|
9
|
-
"variations": Array [
|
|
10
|
-
Object {
|
|
11
|
-
"attributes": Object {},
|
|
12
|
-
"description": "A link to a custom URL.",
|
|
13
|
-
"isActive": [Function],
|
|
14
|
-
"isDefault": true,
|
|
15
|
-
"name": "link",
|
|
16
|
-
"title": "Custom Link",
|
|
17
|
-
},
|
|
18
|
-
Object {
|
|
19
|
-
"attributes": Object {
|
|
20
|
-
"kind": "post-type",
|
|
21
|
-
"type": "post",
|
|
22
|
-
},
|
|
23
|
-
"description": "A link to a post.",
|
|
24
|
-
"icon": <SVG
|
|
25
|
-
viewBox="0 0 24 24"
|
|
26
|
-
xmlns="https://www.w3.org/2000/svg"
|
|
27
|
-
>
|
|
28
|
-
<Path
|
|
29
|
-
d="M4 20h16v-1.5H4V20zm0-4.8h16v-1.5H4v1.5zm0-6.4v1.5h16V8.8H4zM16 4H4v1.5h12V4z"
|
|
30
|
-
/>
|
|
31
|
-
</SVG>,
|
|
32
|
-
"isActive": [Function],
|
|
33
|
-
"name": "post",
|
|
34
|
-
"title": "Post Link",
|
|
35
|
-
},
|
|
36
|
-
Object {
|
|
37
|
-
"attributes": Object {
|
|
38
|
-
"kind": "post-type",
|
|
39
|
-
"type": "page",
|
|
40
|
-
},
|
|
41
|
-
"description": "A link to a page.",
|
|
42
|
-
"icon": <SVG
|
|
43
|
-
viewBox="0 0 24 24"
|
|
44
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
45
|
-
>
|
|
46
|
-
<Path
|
|
47
|
-
d="M7 5.5h10a.5.5 0 01.5.5v12a.5.5 0 01-.5.5H7a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM17 4H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V6a2 2 0 00-2-2zm-1 3.75H8v1.5h8v-1.5zM8 11h8v1.5H8V11zm6 3.25H8v1.5h6v-1.5z"
|
|
48
|
-
/>
|
|
49
|
-
</SVG>,
|
|
50
|
-
"isActive": [Function],
|
|
51
|
-
"name": "page",
|
|
52
|
-
"title": "Page Link",
|
|
53
|
-
},
|
|
54
|
-
Object {
|
|
55
|
-
"attributes": Object {
|
|
56
|
-
"kind": "taxonomy",
|
|
57
|
-
"type": "category",
|
|
58
|
-
},
|
|
59
|
-
"description": "A link to a category.",
|
|
60
|
-
"icon": <SVG
|
|
61
|
-
viewBox="0 0 24 24"
|
|
62
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
63
|
-
>
|
|
64
|
-
<Path
|
|
65
|
-
clipRule="evenodd"
|
|
66
|
-
d="M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z"
|
|
67
|
-
fillRule="evenodd"
|
|
68
|
-
/>
|
|
69
|
-
</SVG>,
|
|
70
|
-
"isActive": [Function],
|
|
71
|
-
"name": "category",
|
|
72
|
-
"title": "Category Link",
|
|
73
|
-
},
|
|
74
|
-
Object {
|
|
75
|
-
"attributes": Object {
|
|
76
|
-
"kind": "taxonomy",
|
|
77
|
-
"type": "tag",
|
|
78
|
-
},
|
|
79
|
-
"description": "A link to a tag.",
|
|
80
|
-
"icon": <SVG
|
|
81
|
-
viewBox="0 0 24 24"
|
|
82
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
83
|
-
>
|
|
84
|
-
<Path
|
|
85
|
-
d="M20.1 11.2l-6.7-6.7c-.1-.1-.3-.2-.5-.2H5c-.4-.1-.8.3-.8.7v7.8c0 .2.1.4.2.5l6.7 6.7c.2.2.5.4.7.5s.6.2.9.2c.3 0 .6-.1.9-.2.3-.1.5-.3.8-.5l5.6-5.6c.4-.4.7-1 .7-1.6.1-.6-.2-1.2-.6-1.6zM19 13.4L13.4 19c-.1.1-.2.1-.3.2-.2.1-.4.1-.6 0-.1 0-.2-.1-.3-.2l-6.5-6.5V5.8h6.8l6.5 6.5c.2.2.2.4.2.6 0 .1 0 .3-.2.5zM9 8c-.6 0-1 .4-1 1s.4 1 1 1 1-.4 1-1-.4-1-1-1z"
|
|
86
|
-
/>
|
|
87
|
-
</SVG>,
|
|
88
|
-
"isActive": [Function],
|
|
89
|
-
"name": "tag",
|
|
90
|
-
"title": "Tag Link",
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
}
|
|
94
|
-
`;
|
|
95
|
-
|
|
96
3
|
exports[`hooks enhanceNavigationLinkVariations enhances variations with icon and isActive functions 1`] = `
|
|
97
4
|
Object {
|
|
98
5
|
"extraProp": "extraProp",
|
|
@@ -26,18 +26,6 @@ describe( 'hooks', () => {
|
|
|
26
26
|
three: 'three',
|
|
27
27
|
} );
|
|
28
28
|
} );
|
|
29
|
-
it( 'adds fallback variations when variations are missing', () => {
|
|
30
|
-
const updatedSettings = enhanceNavigationLinkVariations(
|
|
31
|
-
{
|
|
32
|
-
name: 'core/navigation-link',
|
|
33
|
-
one: 'one',
|
|
34
|
-
two: 'two',
|
|
35
|
-
three: 'three',
|
|
36
|
-
},
|
|
37
|
-
'core/navigation-link'
|
|
38
|
-
);
|
|
39
|
-
expect( updatedSettings ).toMatchSnapshot();
|
|
40
|
-
} );
|
|
41
29
|
it( 'enhances variations with icon and isActive functions', () => {
|
|
42
30
|
const updatedSettings = enhanceNavigationLinkVariations(
|
|
43
31
|
{
|
|
@@ -3,8 +3,6 @@ const closeSubmenus = ( element ) => {
|
|
|
3
3
|
.querySelectorAll( '[aria-expanded="true"]' )
|
|
4
4
|
.forEach( ( toggle ) => {
|
|
5
5
|
toggle.setAttribute( 'aria-expanded', 'false' );
|
|
6
|
-
// Always focus the trigger, this becomes especially useful in closing submenus with escape key to ensure focus doesn't get trapped.
|
|
7
|
-
toggle.focus();
|
|
8
6
|
} );
|
|
9
7
|
};
|
|
10
8
|
|
|
@@ -57,11 +55,13 @@ document.addEventListener( 'keyup', function ( event ) {
|
|
|
57
55
|
'.wp-block-navigation-submenu'
|
|
58
56
|
);
|
|
59
57
|
submenuBlocks.forEach( ( block ) => {
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
if ( ! block.contains( event.target ) ) {
|
|
59
|
+
closeSubmenus( block );
|
|
60
|
+
} else if ( event.key === 'Escape' ) {
|
|
61
|
+
const toggle = block.querySelector( '[aria-expanded="true"]' );
|
|
64
62
|
closeSubmenus( block );
|
|
63
|
+
// Focus the submenu trigger so focus does not get trapped in the closed submenu.
|
|
64
|
+
toggle?.focus();
|
|
65
65
|
}
|
|
66
66
|
} );
|
|
67
67
|
} );
|
package/src/nextpage/edit.js
CHANGED
|
@@ -7,9 +7,7 @@ import { useBlockProps } from '@wordpress/block-editor';
|
|
|
7
7
|
export default function NextPageEdit() {
|
|
8
8
|
return (
|
|
9
9
|
<div { ...useBlockProps() }>
|
|
10
|
-
<
|
|
11
|
-
<span>{ __( 'Page break' ) }</span>
|
|
12
|
-
</div>
|
|
10
|
+
<span>{ __( 'Page break' ) }</span>
|
|
13
11
|
</div>
|
|
14
12
|
);
|
|
15
13
|
}
|
package/src/page-list/edit.js
CHANGED
|
@@ -76,11 +76,9 @@ export default function PageListEdit( { context, clientId } ) {
|
|
|
76
76
|
|
|
77
77
|
{ hasResolvedPages && totalPages === null && (
|
|
78
78
|
<div { ...blockProps }>
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
</Notice>
|
|
83
|
-
</div>
|
|
79
|
+
<Notice status={ 'warning' } isDismissible={ false }>
|
|
80
|
+
{ __( 'Page List: Cannot retrieve Pages.' ) }
|
|
81
|
+
</Notice>
|
|
84
82
|
</div>
|
|
85
83
|
) }
|
|
86
84
|
|