@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
|
@@ -62,13 +62,10 @@ export default function PostCommentsFormEdit( {
|
|
|
62
62
|
|
|
63
63
|
if ( ! isSiteEditor && 'open' !== commentStatus ) {
|
|
64
64
|
if ( 'closed' === commentStatus ) {
|
|
65
|
-
warning =
|
|
66
|
-
|
|
67
|
-
__(
|
|
68
|
-
'Post Comments Form block: Comments on this %s are not allowed.'
|
|
69
|
-
),
|
|
70
|
-
postType
|
|
65
|
+
warning = __(
|
|
66
|
+
'Post Comments Form block: Comments are not enabled for this item.'
|
|
71
67
|
);
|
|
68
|
+
|
|
72
69
|
actions = [
|
|
73
70
|
<Button
|
|
74
71
|
key="enableComments"
|
|
@@ -86,7 +83,7 @@ export default function PostCommentsFormEdit( {
|
|
|
86
83
|
warning = sprintf(
|
|
87
84
|
/* translators: 1: Post type (i.e. "post", "page") */
|
|
88
85
|
__(
|
|
89
|
-
'Post Comments Form block: Comments for this post type (%s)
|
|
86
|
+
'Post Comments Form block: Comments are not enabled for this post type (%s).'
|
|
90
87
|
),
|
|
91
88
|
postType
|
|
92
89
|
);
|
|
@@ -44,24 +44,16 @@ function render_block_core_post_template( $attributes, $content, $block ) {
|
|
|
44
44
|
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
|
|
45
45
|
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
// Override the custom query with the global query if needed.
|
|
47
|
+
// Use global query if needed.
|
|
49
48
|
$use_global_query = ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] );
|
|
50
49
|
if ( $use_global_query ) {
|
|
51
50
|
global $wp_query;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if ( empty( $query_args['post_type'] ) && is_singular() ) {
|
|
58
|
-
$query_args['post_type'] = get_post_type( get_the_ID() );
|
|
59
|
-
}
|
|
60
|
-
}
|
|
51
|
+
$query = $wp_query;
|
|
52
|
+
} else {
|
|
53
|
+
$query_args = build_query_vars_from_query_block( $block, $page );
|
|
54
|
+
$query = new WP_Query( $query_args );
|
|
61
55
|
}
|
|
62
56
|
|
|
63
|
-
$query = new WP_Query( $query_args );
|
|
64
|
-
|
|
65
57
|
if ( ! $query->have_posts() ) {
|
|
66
58
|
return '';
|
|
67
59
|
}
|
|
@@ -107,7 +99,9 @@ function render_block_core_post_template( $attributes, $content, $block ) {
|
|
|
107
99
|
$content .= '<li class="' . esc_attr( $post_classes ) . '">' . $block_content . '</li>';
|
|
108
100
|
}
|
|
109
101
|
|
|
110
|
-
|
|
102
|
+
if ( ! $use_global_query ) {
|
|
103
|
+
wp_reset_postdata();
|
|
104
|
+
}
|
|
111
105
|
|
|
112
106
|
return sprintf(
|
|
113
107
|
'<ul %1$s>%2$s</ul>',
|
package/src/post-terms/index.js
CHANGED
|
@@ -19,7 +19,7 @@ export const settings = {
|
|
|
19
19
|
edit,
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
// Importing this file includes side effects. This is
|
|
22
|
+
// Importing this file includes side effects. This is added in block-library/package.json under sideEffects
|
|
23
23
|
addFilter(
|
|
24
24
|
'blocks.registerBlockType',
|
|
25
25
|
'core/template-part',
|
package/src/query/editor.scss
CHANGED
package/src/query/index.js
CHANGED
|
@@ -25,6 +25,6 @@ export const settings = {
|
|
|
25
25
|
deprecated,
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
// Importing this file includes side effects and is
|
|
28
|
+
// Importing this file includes side effects and is added
|
|
29
29
|
// in block-library/package.json under `sideEffects`.
|
|
30
30
|
addFilter( 'editor.BlockEdit', 'core/query', queryInspectorControls );
|
|
@@ -19,24 +19,26 @@ function render_block_core_query_no_results( $attributes, $content, $block ) {
|
|
|
19
19
|
return '';
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
$page_key
|
|
23
|
-
$page
|
|
24
|
-
|
|
22
|
+
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
|
|
23
|
+
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ];
|
|
24
|
+
|
|
25
25
|
// Override the custom query with the global query if needed.
|
|
26
26
|
$use_global_query = ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] );
|
|
27
27
|
if ( $use_global_query ) {
|
|
28
28
|
global $wp_query;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
$query = $wp_query;
|
|
30
|
+
} else {
|
|
31
|
+
$query_args = build_query_vars_from_query_block( $block, $page );
|
|
32
|
+
$query = new WP_Query( $query_args );
|
|
32
33
|
}
|
|
33
|
-
$query = new WP_Query( $query_args );
|
|
34
34
|
|
|
35
35
|
if ( $query->have_posts() ) {
|
|
36
36
|
return '';
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
if ( ! $use_global_query ) {
|
|
40
|
+
wp_reset_postdata();
|
|
41
|
+
}
|
|
40
42
|
|
|
41
43
|
return sprintf(
|
|
42
44
|
'<div %1$s>%2$s</div>',
|
package/src/search/theme.scss
CHANGED
package/src/site-logo/edit.js
CHANGED
|
@@ -358,7 +358,6 @@ export default function LogoEdit( {
|
|
|
358
358
|
isSelected,
|
|
359
359
|
} ) {
|
|
360
360
|
const { width, shouldSyncIcon } = attributes;
|
|
361
|
-
const [ logoUrl, setLogoUrl ] = useState();
|
|
362
361
|
const ref = useRef();
|
|
363
362
|
|
|
364
363
|
const {
|
|
@@ -420,13 +419,7 @@ export default function LogoEdit( {
|
|
|
420
419
|
site_icon: newValue ?? null,
|
|
421
420
|
} );
|
|
422
421
|
|
|
423
|
-
|
|
424
|
-
if ( mediaItemData ) {
|
|
425
|
-
alt = mediaItemData.alt_text;
|
|
426
|
-
if ( logoUrl !== mediaItemData.source_url ) {
|
|
427
|
-
setLogoUrl( mediaItemData.source_url );
|
|
428
|
-
}
|
|
429
|
-
}
|
|
422
|
+
const { alt_text: alt, source_url: logoUrl } = mediaItemData ?? {};
|
|
430
423
|
|
|
431
424
|
const onInitialSelectLogo = ( media ) => {
|
|
432
425
|
// Initialize the syncSiteIcon toggle. If we currently have no Site logo and no
|
|
@@ -452,7 +445,6 @@ export default function LogoEdit( {
|
|
|
452
445
|
if ( ! media.id && media.url ) {
|
|
453
446
|
// This is a temporary blob image.
|
|
454
447
|
setLogo( undefined );
|
|
455
|
-
setLogoUrl( media.url );
|
|
456
448
|
return;
|
|
457
449
|
}
|
|
458
450
|
|
|
@@ -461,7 +453,6 @@ export default function LogoEdit( {
|
|
|
461
453
|
|
|
462
454
|
const onRemoveLogo = () => {
|
|
463
455
|
setLogo( null );
|
|
464
|
-
setLogoUrl( undefined );
|
|
465
456
|
setAttributes( { width: undefined } );
|
|
466
457
|
};
|
|
467
458
|
|
|
@@ -542,7 +533,7 @@ export default function LogoEdit( {
|
|
|
542
533
|
{ !! logoUrl && logoImage }
|
|
543
534
|
{ ! logoUrl && ! canUserEdit && (
|
|
544
535
|
<Placeholder className="site-logo_placeholder">
|
|
545
|
-
{ isLoading && (
|
|
536
|
+
{ !! isLoading && (
|
|
546
537
|
<span className="components-placeholder__preview">
|
|
547
538
|
<Spinner />
|
|
548
539
|
</span>
|
|
@@ -27,6 +27,22 @@ function render_block_core_social_link( $attributes, $content, $block ) {
|
|
|
27
27
|
return '';
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Prepend emails with `mailto:` if not set.
|
|
32
|
+
* The `is_email` returns false for emails with schema.
|
|
33
|
+
*/
|
|
34
|
+
if ( is_email( $url ) ) {
|
|
35
|
+
$url = 'mailto:' . $url;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Prepend URL with https:// if it doesn't appear to contain a scheme
|
|
40
|
+
* and it's not a relative link starting with //.
|
|
41
|
+
*/
|
|
42
|
+
if ( ! parse_url( $url, PHP_URL_SCHEME ) && ! str_starts_with( $url, '//' ) ) {
|
|
43
|
+
$url = 'https://' . $url;
|
|
44
|
+
}
|
|
45
|
+
|
|
30
46
|
$rel_target_attributes = '';
|
|
31
47
|
if ( $open_in_new_tab ) {
|
|
32
48
|
$rel_target_attributes = 'rel="noopener nofollow" target="_blank"';
|
package/src/style.scss
CHANGED
|
@@ -47,7 +47,7 @@ export const settings = {
|
|
|
47
47
|
edit,
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
// Importing this file includes side effects. This is
|
|
50
|
+
// Importing this file includes side effects. This is added in block-library/package.json under sideEffects
|
|
51
51
|
addFilter(
|
|
52
52
|
'blocks.registerBlockType',
|
|
53
53
|
'core/template-part',
|
|
@@ -10,11 +10,6 @@ import {
|
|
|
10
10
|
symbolFilled as symbolFilledIcon,
|
|
11
11
|
} from '@wordpress/icons';
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import fallbackVariations from './fallback-variations';
|
|
17
|
-
|
|
18
13
|
function getTemplatePartIcon( iconName ) {
|
|
19
14
|
if ( 'header' === iconName ) {
|
|
20
15
|
return headerIcon;
|
|
@@ -31,12 +26,6 @@ export function enhanceTemplatePartVariations( settings, name ) {
|
|
|
31
26
|
return settings;
|
|
32
27
|
}
|
|
33
28
|
|
|
34
|
-
// WordPress versions pre-5.8 do not support server side variation registration.
|
|
35
|
-
// So we must register the fallback variations until those versions are no longer supported.
|
|
36
|
-
if ( ! ( settings.variations && settings.variations.length ) ) {
|
|
37
|
-
return { ...settings, variations: fallbackVariations };
|
|
38
|
-
}
|
|
39
|
-
|
|
40
29
|
if ( settings.variations ) {
|
|
41
30
|
const isActive = ( blockAttributes, variationAttributes ) => {
|
|
42
31
|
const { area, theme, slug } = blockAttributes;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { isEmpty,
|
|
4
|
+
import { isEmpty, mapValues, pickBy } from 'lodash';
|
|
5
|
+
|
|
6
|
+
const identity = ( x ) => x;
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Removed empty nodes from nested objects.
|
|
@@ -10,7 +12,11 @@ import { isEmpty, isObject, identity, mapValues, pickBy } from 'lodash';
|
|
|
10
12
|
* @return {Object} Object cleaned from empty nodes.
|
|
11
13
|
*/
|
|
12
14
|
const cleanEmptyObject = ( object ) => {
|
|
13
|
-
if (
|
|
15
|
+
if (
|
|
16
|
+
object === null ||
|
|
17
|
+
typeof object !== 'object' ||
|
|
18
|
+
Array.isArray( object )
|
|
19
|
+
) {
|
|
14
20
|
return object;
|
|
15
21
|
}
|
|
16
22
|
const cleanedNestedObjects = pickBy(
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = useShortCodeTransform;
|
|
7
|
-
|
|
8
|
-
var _lodash = require("lodash");
|
|
9
|
-
|
|
10
|
-
var _data = require("@wordpress/data");
|
|
11
|
-
|
|
12
|
-
var _coreData = require("@wordpress/core-data");
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* External dependencies
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* WordPress dependencies
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Shortcode transforms don't currently have a tranform method and so can't use a selector to
|
|
24
|
-
* retrieve the data for each image being transformer, so this selector handle this post transformation.
|
|
25
|
-
*
|
|
26
|
-
* @param {Array} shortCodeTransforms An array of image data passed from the shortcode transform.
|
|
27
|
-
*
|
|
28
|
-
* @return {Array} An array of extended image data objects for each of the shortcode transform images.
|
|
29
|
-
*/
|
|
30
|
-
function useShortCodeTransform(shortCodeTransforms) {
|
|
31
|
-
const newImageData = (0, _data.useSelect)(select => {
|
|
32
|
-
if (!shortCodeTransforms || shortCodeTransforms.length === 0) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const imageIds = shortCodeTransforms.map(image => image.id);
|
|
37
|
-
return select(_coreData.store).getMediaItems({
|
|
38
|
-
include: imageIds.join(','),
|
|
39
|
-
per_page: imageIds.length,
|
|
40
|
-
orderby: 'include'
|
|
41
|
-
});
|
|
42
|
-
}, [shortCodeTransforms]);
|
|
43
|
-
|
|
44
|
-
if (!newImageData) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if ((0, _lodash.every)(newImageData, img => img && img.source_url)) {
|
|
49
|
-
return newImageData.map(imageData => {
|
|
50
|
-
var _imageData$caption;
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
id: imageData.id,
|
|
54
|
-
type: 'image',
|
|
55
|
-
url: imageData.source_url,
|
|
56
|
-
mime: imageData.mime_type,
|
|
57
|
-
alt: imageData.alt_text,
|
|
58
|
-
link: imageData.link,
|
|
59
|
-
caption: imageData === null || imageData === void 0 ? void 0 : (_imageData$caption = imageData.caption) === null || _imageData$caption === void 0 ? void 0 : _imageData$caption.raw
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=use-short-code-transform.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/gallery/use-short-code-transform.js"],"names":["useShortCodeTransform","shortCodeTransforms","newImageData","select","length","imageIds","map","image","id","coreStore","getMediaItems","include","join","per_page","orderby","img","source_url","imageData","type","url","mime","mime_type","alt","alt_text","link","caption","raw"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,qBAAT,CAAgCC,mBAAhC,EAAsD;AACpE,QAAMC,YAAY,GAAG,qBAClBC,MAAF,IAAc;AACb,QAAK,CAAEF,mBAAF,IAAyBA,mBAAmB,CAACG,MAApB,KAA+B,CAA7D,EAAiE;AAChE;AACA;;AAED,UAAMC,QAAQ,GAAGJ,mBAAmB,CAACK,GAApB,CAA2BC,KAAF,IAAaA,KAAK,CAACC,EAA5C,CAAjB;AAEA,WAAOL,MAAM,CAAEM,eAAF,CAAN,CAAoBC,aAApB,CAAmC;AACzCC,MAAAA,OAAO,EAAEN,QAAQ,CAACO,IAAT,CAAe,GAAf,CADgC;AAEzCC,MAAAA,QAAQ,EAAER,QAAQ,CAACD,MAFsB;AAGzCU,MAAAA,OAAO,EAAE;AAHgC,KAAnC,CAAP;AAKA,GAbmB,EAcpB,CAAEb,mBAAF,CAdoB,CAArB;;AAiBA,MAAK,CAAEC,YAAP,EAAsB;AACrB;AACA;;AAED,MAAK,mBAAOA,YAAP,EAAuBa,GAAF,IAAWA,GAAG,IAAIA,GAAG,CAACC,UAA3C,CAAL,EAA+D;AAC9D,WAAOd,YAAY,CAACI,GAAb,CAAoBW,SAAF,IAAiB;AAAA;;AACzC,aAAO;AACNT,QAAAA,EAAE,EAAES,SAAS,CAACT,EADR;AAENU,QAAAA,IAAI,EAAE,OAFA;AAGNC,QAAAA,GAAG,EAAEF,SAAS,CAACD,UAHT;AAINI,QAAAA,IAAI,EAAEH,SAAS,CAACI,SAJV;AAKNC,QAAAA,GAAG,EAAEL,SAAS,CAACM,QALT;AAMNC,QAAAA,IAAI,EAAEP,SAAS,CAACO,IANV;AAONC,QAAAA,OAAO,EAAER,SAAF,aAAEA,SAAF,6CAAEA,SAAS,CAAEQ,OAAb,uDAAE,mBAAoBC;AAPvB,OAAP;AASA,KAVM,CAAP;AAWA;AACD","sourcesContent":["/**\n * External dependencies\n */\nimport { every } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Shortcode transforms don't currently have a tranform method and so can't use a selector to\n * retrieve the data for each image being transformer, so this selector handle this post transformation.\n *\n * @param {Array} shortCodeTransforms An array of image data passed from the shortcode transform.\n *\n * @return {Array} An array of extended image data objects for each of the shortcode transform images.\n */\nexport default function useShortCodeTransform( shortCodeTransforms ) {\n\tconst newImageData = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! shortCodeTransforms || shortCodeTransforms.length === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst imageIds = shortCodeTransforms.map( ( image ) => image.id );\n\n\t\t\treturn select( coreStore ).getMediaItems( {\n\t\t\t\tinclude: imageIds.join( ',' ),\n\t\t\t\tper_page: imageIds.length,\n\t\t\t\torderby: 'include',\n\t\t\t} );\n\t\t},\n\t\t[ shortCodeTransforms ]\n\t);\n\n\tif ( ! newImageData ) {\n\t\treturn;\n\t}\n\n\tif ( every( newImageData, ( img ) => img && img.source_url ) ) {\n\t\treturn newImageData.map( ( imageData ) => {\n\t\t\treturn {\n\t\t\t\tid: imageData.id,\n\t\t\t\ttype: 'image',\n\t\t\t\turl: imageData.source_url,\n\t\t\t\tmime: imageData.mime_type,\n\t\t\t\talt: imageData.alt_text,\n\t\t\t\tlink: imageData.link,\n\t\t\t\tcaption: imageData?.caption?.raw,\n\t\t\t};\n\t\t} );\n\t}\n}\n"]}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _i18n = require("@wordpress/i18n");
|
|
9
|
-
|
|
10
|
-
var _icons = require("@wordpress/icons");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* WordPress dependencies
|
|
14
|
-
*/
|
|
15
|
-
// FALLBACK: this is only used when the server does not understand the variations property in the
|
|
16
|
-
// register_block_type call. see navigation-link/index.php.
|
|
17
|
-
// Delete this file when supported WP ranges understand the `variations` property when passed to
|
|
18
|
-
// register_block_type in index.php.
|
|
19
|
-
const fallbackVariations = [{
|
|
20
|
-
name: 'link',
|
|
21
|
-
isDefault: true,
|
|
22
|
-
title: (0, _i18n.__)('Custom Link'),
|
|
23
|
-
description: (0, _i18n.__)('A link to a custom URL.'),
|
|
24
|
-
attributes: {}
|
|
25
|
-
}, {
|
|
26
|
-
name: 'post',
|
|
27
|
-
icon: _icons.postContent,
|
|
28
|
-
title: (0, _i18n.__)('Post Link'),
|
|
29
|
-
description: (0, _i18n.__)('A link to a post.'),
|
|
30
|
-
attributes: {
|
|
31
|
-
type: 'post',
|
|
32
|
-
kind: 'post-type'
|
|
33
|
-
}
|
|
34
|
-
}, {
|
|
35
|
-
name: 'page',
|
|
36
|
-
icon: _icons.page,
|
|
37
|
-
title: (0, _i18n.__)('Page Link'),
|
|
38
|
-
description: (0, _i18n.__)('A link to a page.'),
|
|
39
|
-
attributes: {
|
|
40
|
-
type: 'page',
|
|
41
|
-
kind: 'post-type'
|
|
42
|
-
}
|
|
43
|
-
}, {
|
|
44
|
-
name: 'category',
|
|
45
|
-
icon: _icons.category,
|
|
46
|
-
title: (0, _i18n.__)('Category Link'),
|
|
47
|
-
description: (0, _i18n.__)('A link to a category.'),
|
|
48
|
-
attributes: {
|
|
49
|
-
type: 'category',
|
|
50
|
-
kind: 'taxonomy'
|
|
51
|
-
}
|
|
52
|
-
}, {
|
|
53
|
-
name: 'tag',
|
|
54
|
-
icon: _icons.tag,
|
|
55
|
-
title: (0, _i18n.__)('Tag Link'),
|
|
56
|
-
description: (0, _i18n.__)('A link to a tag.'),
|
|
57
|
-
attributes: {
|
|
58
|
-
type: 'tag',
|
|
59
|
-
kind: 'taxonomy'
|
|
60
|
-
}
|
|
61
|
-
}];
|
|
62
|
-
/**
|
|
63
|
-
* Add `isActive` function to all `navigation link` variations, if not defined.
|
|
64
|
-
* `isActive` function is used to find a variation match from a created
|
|
65
|
-
* Block by providing its attributes.
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
fallbackVariations.forEach(variation => {
|
|
69
|
-
if (variation.isActive) return;
|
|
70
|
-
|
|
71
|
-
variation.isActive = (blockAttributes, variationAttributes) => blockAttributes.type === variationAttributes.type;
|
|
72
|
-
});
|
|
73
|
-
var _default = fallbackVariations;
|
|
74
|
-
exports.default = _default;
|
|
75
|
-
//# sourceMappingURL=fallback-variations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/navigation-link/fallback-variations.js"],"names":["fallbackVariations","name","isDefault","title","description","attributes","icon","postIcon","type","kind","pageIcon","categoryIcon","tagIcon","forEach","variation","isActive","blockAttributes","variationAttributes"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AASA;AACA;AACA;AACA;AACA,MAAMA,kBAAkB,GAAG,CAC1B;AACCC,EAAAA,IAAI,EAAE,MADP;AAECC,EAAAA,SAAS,EAAE,IAFZ;AAGCC,EAAAA,KAAK,EAAE,cAAI,aAAJ,CAHR;AAICC,EAAAA,WAAW,EAAE,cAAI,yBAAJ,CAJd;AAKCC,EAAAA,UAAU,EAAE;AALb,CAD0B,EAQ1B;AACCJ,EAAAA,IAAI,EAAE,MADP;AAECK,EAAAA,IAAI,EAAEC,kBAFP;AAGCJ,EAAAA,KAAK,EAAE,cAAI,WAAJ,CAHR;AAICC,EAAAA,WAAW,EAAE,cAAI,mBAAJ,CAJd;AAKCC,EAAAA,UAAU,EAAE;AAAEG,IAAAA,IAAI,EAAE,MAAR;AAAgBC,IAAAA,IAAI,EAAE;AAAtB;AALb,CAR0B,EAe1B;AACCR,EAAAA,IAAI,EAAE,MADP;AAECK,EAAAA,IAAI,EAAEI,WAFP;AAGCP,EAAAA,KAAK,EAAE,cAAI,WAAJ,CAHR;AAICC,EAAAA,WAAW,EAAE,cAAI,mBAAJ,CAJd;AAKCC,EAAAA,UAAU,EAAE;AAAEG,IAAAA,IAAI,EAAE,MAAR;AAAgBC,IAAAA,IAAI,EAAE;AAAtB;AALb,CAf0B,EAsB1B;AACCR,EAAAA,IAAI,EAAE,UADP;AAECK,EAAAA,IAAI,EAAEK,eAFP;AAGCR,EAAAA,KAAK,EAAE,cAAI,eAAJ,CAHR;AAICC,EAAAA,WAAW,EAAE,cAAI,uBAAJ,CAJd;AAKCC,EAAAA,UAAU,EAAE;AAAEG,IAAAA,IAAI,EAAE,UAAR;AAAoBC,IAAAA,IAAI,EAAE;AAA1B;AALb,CAtB0B,EA6B1B;AACCR,EAAAA,IAAI,EAAE,KADP;AAECK,EAAAA,IAAI,EAAEM,UAFP;AAGCT,EAAAA,KAAK,EAAE,cAAI,UAAJ,CAHR;AAICC,EAAAA,WAAW,EAAE,cAAI,kBAAJ,CAJd;AAKCC,EAAAA,UAAU,EAAE;AAAEG,IAAAA,IAAI,EAAE,KAAR;AAAeC,IAAAA,IAAI,EAAE;AAArB;AALb,CA7B0B,CAA3B;AAsCA;AACA;AACA;AACA;AACA;;AACAT,kBAAkB,CAACa,OAAnB,CAA8BC,SAAF,IAAiB;AAC5C,MAAKA,SAAS,CAACC,QAAf,EAA0B;;AAC1BD,EAAAA,SAAS,CAACC,QAAV,GAAqB,CAAEC,eAAF,EAAmBC,mBAAnB,KACpBD,eAAe,CAACR,IAAhB,KAAyBS,mBAAmB,CAACT,IAD9C;AAEA,CAJD;eAMeR,kB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tcategory as categoryIcon,\n\tpage as pageIcon,\n\tpostContent as postIcon,\n\ttag as tagIcon,\n} from '@wordpress/icons';\n\n// FALLBACK: this is only used when the server does not understand the variations property in the\n// register_block_type call. see navigation-link/index.php.\n// Delete this file when supported WP ranges understand the `variations` property when passed to\n// register_block_type in index.php.\nconst fallbackVariations = [\n\t{\n\t\tname: 'link',\n\t\tisDefault: true,\n\t\ttitle: __( 'Custom Link' ),\n\t\tdescription: __( 'A link to a custom URL.' ),\n\t\tattributes: {},\n\t},\n\t{\n\t\tname: 'post',\n\t\ticon: postIcon,\n\t\ttitle: __( 'Post Link' ),\n\t\tdescription: __( 'A link to a post.' ),\n\t\tattributes: { type: 'post', kind: 'post-type' },\n\t},\n\t{\n\t\tname: 'page',\n\t\ticon: pageIcon,\n\t\ttitle: __( 'Page Link' ),\n\t\tdescription: __( 'A link to a page.' ),\n\t\tattributes: { type: 'page', kind: 'post-type' },\n\t},\n\t{\n\t\tname: 'category',\n\t\ticon: categoryIcon,\n\t\ttitle: __( 'Category Link' ),\n\t\tdescription: __( 'A link to a category.' ),\n\t\tattributes: { type: 'category', kind: 'taxonomy' },\n\t},\n\t{\n\t\tname: 'tag',\n\t\ticon: tagIcon,\n\t\ttitle: __( 'Tag Link' ),\n\t\tdescription: __( 'A link to a tag.' ),\n\t\tattributes: { type: 'tag', kind: 'taxonomy' },\n\t},\n];\n\n/**\n * Add `isActive` function to all `navigation link` variations, if not defined.\n * `isActive` function is used to find a variation match from a created\n * Block by providing its attributes.\n */\nfallbackVariations.forEach( ( variation ) => {\n\tif ( variation.isActive ) return;\n\tvariation.isActive = ( blockAttributes, variationAttributes ) =>\n\t\tblockAttributes.type === variationAttributes.type;\n} );\n\nexport default fallbackVariations;\n"]}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _i18n = require("@wordpress/i18n");
|
|
9
|
-
|
|
10
|
-
var _icons = require("@wordpress/icons");
|
|
11
|
-
|
|
12
|
-
var _coreData = require("@wordpress/core-data");
|
|
13
|
-
|
|
14
|
-
var _data = require("@wordpress/data");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
const fallbackVariations = [{
|
|
20
|
-
name: 'header',
|
|
21
|
-
icon: _icons.header,
|
|
22
|
-
title: (0, _i18n.__)('Header'),
|
|
23
|
-
description: (0, _i18n.__)('The Header template defines a page area that typically contains a title, logo, and main navigation.'),
|
|
24
|
-
attributes: {
|
|
25
|
-
area: 'header'
|
|
26
|
-
},
|
|
27
|
-
scope: ['inserter']
|
|
28
|
-
}, {
|
|
29
|
-
name: 'footer',
|
|
30
|
-
icon: _icons.footer,
|
|
31
|
-
title: (0, _i18n.__)('Footer'),
|
|
32
|
-
description: (0, _i18n.__)('The Footer template defines a page area that typically contains site credits, social links, or any other combination of blocks.'),
|
|
33
|
-
attributes: {
|
|
34
|
-
area: 'footer'
|
|
35
|
-
},
|
|
36
|
-
scope: ['inserter']
|
|
37
|
-
}];
|
|
38
|
-
fallbackVariations.forEach(variation => {
|
|
39
|
-
if (variation.isActive) return;
|
|
40
|
-
|
|
41
|
-
variation.isActive = (blockAttributes, variationAttributes) => {
|
|
42
|
-
const {
|
|
43
|
-
area,
|
|
44
|
-
theme,
|
|
45
|
-
slug
|
|
46
|
-
} = blockAttributes; // We first check the `area` block attribute which is set during insertion.
|
|
47
|
-
// This property is removed on the creation of a template part.
|
|
48
|
-
|
|
49
|
-
if (area) return area === variationAttributes.area; // Find a matching variation from the created template part
|
|
50
|
-
// by checking the entity's `area` property.
|
|
51
|
-
|
|
52
|
-
if (!slug) return false;
|
|
53
|
-
const entity = (0, _data.select)(_coreData.store).getEntityRecord('postType', 'wp_template_part', `${theme}//${slug}`);
|
|
54
|
-
return (entity === null || entity === void 0 ? void 0 : entity.area) === variationAttributes.area;
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
var _default = fallbackVariations;
|
|
58
|
-
exports.default = _default;
|
|
59
|
-
//# sourceMappingURL=fallback-variations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/template-part/fallback-variations.js"],"names":["fallbackVariations","name","icon","headerIcon","title","description","attributes","area","scope","footerIcon","forEach","variation","isActive","blockAttributes","variationAttributes","theme","slug","entity","coreDataStore","getEntityRecord"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,kBAAkB,GAAG,CAC1B;AACCC,EAAAA,IAAI,EAAE,QADP;AAECC,EAAAA,IAAI,EAAEC,aAFP;AAGCC,EAAAA,KAAK,EAAE,cAAI,QAAJ,CAHR;AAICC,EAAAA,WAAW,EAAE,cACZ,qGADY,CAJd;AAOCC,EAAAA,UAAU,EAAE;AAAEC,IAAAA,IAAI,EAAE;AAAR,GAPb;AAQCC,EAAAA,KAAK,EAAE,CAAE,UAAF;AARR,CAD0B,EAW1B;AACCP,EAAAA,IAAI,EAAE,QADP;AAECC,EAAAA,IAAI,EAAEO,aAFP;AAGCL,EAAAA,KAAK,EAAE,cAAI,QAAJ,CAHR;AAICC,EAAAA,WAAW,EAAE,cACZ,iIADY,CAJd;AAOCC,EAAAA,UAAU,EAAE;AAAEC,IAAAA,IAAI,EAAE;AAAR,GAPb;AAQCC,EAAAA,KAAK,EAAE,CAAE,UAAF;AARR,CAX0B,CAA3B;AAuBAR,kBAAkB,CAACU,OAAnB,CAA8BC,SAAF,IAAiB;AAC5C,MAAKA,SAAS,CAACC,QAAf,EAA0B;;AAC1BD,EAAAA,SAAS,CAACC,QAAV,GAAqB,CAAEC,eAAF,EAAmBC,mBAAnB,KAA4C;AAChE,UAAM;AAAEP,MAAAA,IAAF;AAAQQ,MAAAA,KAAR;AAAeC,MAAAA;AAAf,QAAwBH,eAA9B,CADgE,CAEhE;AACA;;AACA,QAAKN,IAAL,EAAY,OAAOA,IAAI,KAAKO,mBAAmB,CAACP,IAApC,CAJoD,CAKhE;AACA;;AACA,QAAK,CAAES,IAAP,EAAc,OAAO,KAAP;AACd,UAAMC,MAAM,GAAG,kBAAQC,eAAR,EAAwBC,eAAxB,CACd,UADc,EAEd,kBAFc,EAGb,GAAGJ,KAAO,KAAKC,IAAM,EAHR,CAAf;AAKA,WAAO,CAAAC,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEV,IAAR,MAAiBO,mBAAmB,CAACP,IAA5C;AACA,GAdD;AAeA,CAjBD;eAmBeP,kB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { header as headerIcon, footer as footerIcon } from '@wordpress/icons';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { select } from '@wordpress/data';\n\nconst fallbackVariations = [\n\t{\n\t\tname: 'header',\n\t\ticon: headerIcon,\n\t\ttitle: __( 'Header' ),\n\t\tdescription: __(\n\t\t\t'The Header template defines a page area that typically contains a title, logo, and main navigation.'\n\t\t),\n\t\tattributes: { area: 'header' },\n\t\tscope: [ 'inserter' ],\n\t},\n\t{\n\t\tname: 'footer',\n\t\ticon: footerIcon,\n\t\ttitle: __( 'Footer' ),\n\t\tdescription: __(\n\t\t\t'The Footer template defines a page area that typically contains site credits, social links, or any other combination of blocks.'\n\t\t),\n\t\tattributes: { area: 'footer' },\n\t\tscope: [ 'inserter' ],\n\t},\n];\n\nfallbackVariations.forEach( ( variation ) => {\n\tif ( variation.isActive ) return;\n\tvariation.isActive = ( blockAttributes, variationAttributes ) => {\n\t\tconst { area, theme, slug } = blockAttributes;\n\t\t// We first check the `area` block attribute which is set during insertion.\n\t\t// This property is removed on the creation of a template part.\n\t\tif ( area ) return area === variationAttributes.area;\n\t\t// Find a matching variation from the created template part\n\t\t// by checking the entity's `area` property.\n\t\tif ( ! slug ) return false;\n\t\tconst entity = select( coreDataStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t`${ theme }//${ slug }`\n\t\t);\n\t\treturn entity?.area === variationAttributes.area;\n\t};\n} );\n\nexport default fallbackVariations;\n"]}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { every } from 'lodash';
|
|
5
|
-
/**
|
|
6
|
-
* WordPress dependencies
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { useSelect } from '@wordpress/data';
|
|
10
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
-
/**
|
|
12
|
-
* Shortcode transforms don't currently have a tranform method and so can't use a selector to
|
|
13
|
-
* retrieve the data for each image being transformer, so this selector handle this post transformation.
|
|
14
|
-
*
|
|
15
|
-
* @param {Array} shortCodeTransforms An array of image data passed from the shortcode transform.
|
|
16
|
-
*
|
|
17
|
-
* @return {Array} An array of extended image data objects for each of the shortcode transform images.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
export default function useShortCodeTransform(shortCodeTransforms) {
|
|
21
|
-
const newImageData = useSelect(select => {
|
|
22
|
-
if (!shortCodeTransforms || shortCodeTransforms.length === 0) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const imageIds = shortCodeTransforms.map(image => image.id);
|
|
27
|
-
return select(coreStore).getMediaItems({
|
|
28
|
-
include: imageIds.join(','),
|
|
29
|
-
per_page: imageIds.length,
|
|
30
|
-
orderby: 'include'
|
|
31
|
-
});
|
|
32
|
-
}, [shortCodeTransforms]);
|
|
33
|
-
|
|
34
|
-
if (!newImageData) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (every(newImageData, img => img && img.source_url)) {
|
|
39
|
-
return newImageData.map(imageData => {
|
|
40
|
-
var _imageData$caption;
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
id: imageData.id,
|
|
44
|
-
type: 'image',
|
|
45
|
-
url: imageData.source_url,
|
|
46
|
-
mime: imageData.mime_type,
|
|
47
|
-
alt: imageData.alt_text,
|
|
48
|
-
link: imageData.link,
|
|
49
|
-
caption: imageData === null || imageData === void 0 ? void 0 : (_imageData$caption = imageData.caption) === null || _imageData$caption === void 0 ? void 0 : _imageData$caption.raw
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=use-short-code-transform.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/gallery/use-short-code-transform.js"],"names":["every","useSelect","store","coreStore","useShortCodeTransform","shortCodeTransforms","newImageData","select","length","imageIds","map","image","id","getMediaItems","include","join","per_page","orderby","img","source_url","imageData","type","url","mime","mime_type","alt","alt_text","link","caption","raw"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,QAAtB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,qBAAT,CAAgCC,mBAAhC,EAAsD;AACpE,QAAMC,YAAY,GAAGL,SAAS,CAC3BM,MAAF,IAAc;AACb,QAAK,CAAEF,mBAAF,IAAyBA,mBAAmB,CAACG,MAApB,KAA+B,CAA7D,EAAiE;AAChE;AACA;;AAED,UAAMC,QAAQ,GAAGJ,mBAAmB,CAACK,GAApB,CAA2BC,KAAF,IAAaA,KAAK,CAACC,EAA5C,CAAjB;AAEA,WAAOL,MAAM,CAAEJ,SAAF,CAAN,CAAoBU,aAApB,CAAmC;AACzCC,MAAAA,OAAO,EAAEL,QAAQ,CAACM,IAAT,CAAe,GAAf,CADgC;AAEzCC,MAAAA,QAAQ,EAAEP,QAAQ,CAACD,MAFsB;AAGzCS,MAAAA,OAAO,EAAE;AAHgC,KAAnC,CAAP;AAKA,GAb4B,EAc7B,CAAEZ,mBAAF,CAd6B,CAA9B;;AAiBA,MAAK,CAAEC,YAAP,EAAsB;AACrB;AACA;;AAED,MAAKN,KAAK,CAAEM,YAAF,EAAkBY,GAAF,IAAWA,GAAG,IAAIA,GAAG,CAACC,UAAtC,CAAV,EAA+D;AAC9D,WAAOb,YAAY,CAACI,GAAb,CAAoBU,SAAF,IAAiB;AAAA;;AACzC,aAAO;AACNR,QAAAA,EAAE,EAAEQ,SAAS,CAACR,EADR;AAENS,QAAAA,IAAI,EAAE,OAFA;AAGNC,QAAAA,GAAG,EAAEF,SAAS,CAACD,UAHT;AAINI,QAAAA,IAAI,EAAEH,SAAS,CAACI,SAJV;AAKNC,QAAAA,GAAG,EAAEL,SAAS,CAACM,QALT;AAMNC,QAAAA,IAAI,EAAEP,SAAS,CAACO,IANV;AAONC,QAAAA,OAAO,EAAER,SAAF,aAAEA,SAAF,6CAAEA,SAAS,CAAEQ,OAAb,uDAAE,mBAAoBC;AAPvB,OAAP;AASA,KAVM,CAAP;AAWA;AACD","sourcesContent":["/**\n * External dependencies\n */\nimport { every } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Shortcode transforms don't currently have a tranform method and so can't use a selector to\n * retrieve the data for each image being transformer, so this selector handle this post transformation.\n *\n * @param {Array} shortCodeTransforms An array of image data passed from the shortcode transform.\n *\n * @return {Array} An array of extended image data objects for each of the shortcode transform images.\n */\nexport default function useShortCodeTransform( shortCodeTransforms ) {\n\tconst newImageData = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! shortCodeTransforms || shortCodeTransforms.length === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst imageIds = shortCodeTransforms.map( ( image ) => image.id );\n\n\t\t\treturn select( coreStore ).getMediaItems( {\n\t\t\t\tinclude: imageIds.join( ',' ),\n\t\t\t\tper_page: imageIds.length,\n\t\t\t\torderby: 'include',\n\t\t\t} );\n\t\t},\n\t\t[ shortCodeTransforms ]\n\t);\n\n\tif ( ! newImageData ) {\n\t\treturn;\n\t}\n\n\tif ( every( newImageData, ( img ) => img && img.source_url ) ) {\n\t\treturn newImageData.map( ( imageData ) => {\n\t\t\treturn {\n\t\t\t\tid: imageData.id,\n\t\t\t\ttype: 'image',\n\t\t\t\turl: imageData.source_url,\n\t\t\t\tmime: imageData.mime_type,\n\t\t\t\talt: imageData.alt_text,\n\t\t\t\tlink: imageData.link,\n\t\t\t\tcaption: imageData?.caption?.raw,\n\t\t\t};\n\t\t} );\n\t}\n}\n"]}
|