@wordpress/block-library 8.13.0 → 8.14.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/archives/index.js +5 -1
- package/build/archives/index.js.map +1 -1
- package/build/audio/index.js +5 -1
- package/build/audio/index.js.map +1 -1
- package/build/avatar/index.js +1 -1
- package/build/block/edit.js +1 -1
- package/build/block/edit.js.map +1 -1
- package/build/block/edit.native.js +6 -9
- package/build/block/edit.native.js.map +1 -1
- package/build/buttons/edit.js +5 -1
- package/build/buttons/edit.js.map +1 -1
- package/build/categories/index.js +5 -1
- package/build/categories/index.js.map +1 -1
- package/build/code/index.js +5 -1
- package/build/code/index.js.map +1 -1
- package/build/column/index.js +1 -0
- package/build/column/index.js.map +1 -1
- package/build/comments/index.js +1 -0
- package/build/comments/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/cover/index.js +1 -0
- package/build/cover/index.js.map +1 -1
- package/build/details/index.js +5 -1
- package/build/details/index.js.map +1 -1
- package/build/embed/util.js +9 -8
- package/build/embed/util.js.map +1 -1
- package/build/file/index.js +2 -1
- package/build/file/index.js.map +1 -1
- package/build/file/view.js +15 -1
- package/build/file/view.js.map +1 -1
- package/build/gallery/index.js +3 -1
- package/build/gallery/index.js.map +1 -1
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/index.js +5 -1
- package/build/heading/index.js.map +1 -1
- package/build/heading/transforms.js +5 -1
- package/build/heading/transforms.js.map +1 -1
- package/build/image/deprecated.js +453 -175
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.js +0 -4
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +96 -43
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +6 -0
- package/build/image/index.js.map +1 -1
- package/build/image/save.js +8 -1
- package/build/image/save.js.map +1 -1
- package/build/image/utils.js +18 -0
- package/build/image/utils.js.map +1 -1
- package/build/image/{interactivity.js → view-interactivity.js} +86 -44
- package/build/image/view-interactivity.js.map +1 -0
- package/build/index.js +12 -3
- package/build/index.js.map +1 -1
- package/build/list/index.js +5 -1
- package/build/list/index.js.map +1 -1
- package/build/list-item/utils.js +6 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/media-text/index.js +1 -0
- package/build/media-text/index.js.map +1 -1
- package/build/missing/edit.js +22 -8
- package/build/missing/edit.js.map +1 -1
- package/build/navigation/edit/index.js +1 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +0 -1
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation/index.js +3 -2
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/view.js +174 -50
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +0 -11
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/link-ui.js +12 -2
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +3 -3
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/edit.js +34 -39
- package/build/page-list/edit.js.map +1 -1
- package/build/page-list/use-convert-to-navigation-links.js +2 -15
- package/build/page-list/use-convert-to-navigation-links.js.map +1 -1
- package/build/paragraph/index.js +1 -0
- package/build/paragraph/index.js.map +1 -1
- package/build/paragraph/transforms.js +1 -0
- package/build/paragraph/transforms.js.map +1 -1
- package/build/post-comments-form/index.js +1 -0
- package/build/post-comments-form/index.js.map +1 -1
- package/build/post-navigation-link/index.js +1 -0
- package/build/post-navigation-link/index.js.map +1 -1
- package/build/post-time-to-read/index.js +5 -1
- package/build/post-time-to-read/index.js.map +1 -1
- package/build/query-pagination-numbers/index.js +1 -1
- package/build/quote/index.js +1 -0
- package/build/quote/index.js.map +1 -1
- package/build/site-logo/index.js +5 -1
- package/build/site-logo/index.js.map +1 -1
- package/build/site-tagline/icon.js +1 -1
- package/build/site-tagline/icon.js.map +1 -1
- package/build/site-tagline/index.js +5 -1
- package/build/site-tagline/index.js.map +1 -1
- package/build/site-title/index.js +5 -1
- package/build/site-title/index.js.map +1 -1
- package/build/social-links/index.js +3 -1
- package/build/social-links/index.js.map +1 -1
- package/build/table/index.js +5 -1
- package/build/table/index.js.map +1 -1
- package/build/term-description/index.js +1 -0
- package/build/term-description/index.js.map +1 -1
- package/build/verse/index.js +5 -1
- package/build/verse/index.js.map +1 -1
- package/build/video/deprecated.js +5 -1
- package/build/video/deprecated.js.map +1 -1
- package/build/video/index.js +5 -1
- package/build/video/index.js.map +1 -1
- package/build-module/archives/index.js +5 -1
- package/build-module/archives/index.js.map +1 -1
- package/build-module/audio/index.js +5 -1
- package/build-module/audio/index.js.map +1 -1
- package/build-module/avatar/index.js +1 -1
- package/build-module/block/edit.js +1 -1
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/edit.native.js +7 -9
- package/build-module/block/edit.native.js.map +1 -1
- package/build-module/buttons/edit.js +5 -1
- package/build-module/buttons/edit.js.map +1 -1
- package/build-module/categories/index.js +5 -1
- package/build-module/categories/index.js.map +1 -1
- package/build-module/code/index.js +5 -1
- package/build-module/code/index.js.map +1 -1
- package/build-module/column/index.js +1 -0
- package/build-module/column/index.js.map +1 -1
- package/build-module/comments/index.js +1 -0
- package/build-module/comments/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +2 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/index.js +1 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/details/index.js +5 -1
- package/build-module/details/index.js.map +1 -1
- package/build-module/embed/util.js +6 -6
- package/build-module/embed/util.js.map +1 -1
- package/build-module/file/index.js +2 -1
- package/build-module/file/index.js.map +1 -1
- package/build-module/file/view.js +15 -2
- package/build-module/file/view.js.map +1 -1
- package/build-module/gallery/index.js +3 -1
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/index.js +5 -1
- package/build-module/heading/index.js.map +1 -1
- package/build-module/heading/transforms.js +5 -1
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/image/deprecated.js +454 -176
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.js +0 -4
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +96 -46
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +6 -0
- package/build-module/image/index.js.map +1 -1
- package/build-module/image/save.js +8 -1
- package/build-module/image/save.js.map +1 -1
- package/build-module/image/utils.js +16 -0
- package/build-module/image/utils.js.map +1 -1
- package/build-module/image/{interactivity.js → view-interactivity.js} +86 -44
- package/build-module/image/view-interactivity.js.map +1 -0
- package/build-module/index.js +12 -3
- package/build-module/index.js.map +1 -1
- package/build-module/list/index.js +5 -1
- package/build-module/list/index.js.map +1 -1
- package/build-module/list-item/utils.js +6 -1
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/media-text/index.js +1 -0
- package/build-module/media-text/index.js.map +1 -1
- package/build-module/missing/edit.js +22 -8
- package/build-module/missing/edit.js.map +1 -1
- package/build-module/navigation/edit/index.js +1 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +0 -1
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation/index.js +3 -2
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/view.js +173 -50
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +1 -12
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +13 -3
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +3 -3
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/edit.js +34 -39
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/page-list/use-convert-to-navigation-links.js +3 -16
- package/build-module/page-list/use-convert-to-navigation-links.js.map +1 -1
- package/build-module/paragraph/index.js +1 -0
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/paragraph/transforms.js +1 -0
- package/build-module/paragraph/transforms.js.map +1 -1
- package/build-module/post-comments-form/index.js +1 -0
- package/build-module/post-comments-form/index.js.map +1 -1
- package/build-module/post-navigation-link/index.js +1 -0
- package/build-module/post-navigation-link/index.js.map +1 -1
- package/build-module/post-time-to-read/index.js +5 -1
- package/build-module/post-time-to-read/index.js.map +1 -1
- package/build-module/query-pagination-numbers/index.js +1 -1
- package/build-module/quote/index.js +1 -0
- package/build-module/quote/index.js.map +1 -1
- package/build-module/site-logo/index.js +5 -1
- package/build-module/site-logo/index.js.map +1 -1
- package/build-module/site-tagline/icon.js +1 -1
- package/build-module/site-tagline/icon.js.map +1 -1
- package/build-module/site-tagline/index.js +5 -1
- package/build-module/site-tagline/index.js.map +1 -1
- package/build-module/site-title/index.js +5 -1
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-links/index.js +3 -1
- package/build-module/social-links/index.js.map +1 -1
- package/build-module/table/index.js +5 -1
- package/build-module/table/index.js.map +1 -1
- package/build-module/term-description/index.js +1 -0
- package/build-module/term-description/index.js.map +1 -1
- package/build-module/verse/index.js +5 -1
- package/build-module/verse/index.js.map +1 -1
- package/build-module/video/deprecated.js +5 -1
- package/build-module/video/deprecated.js.map +1 -1
- package/build-module/video/index.js +5 -1
- package/build-module/video/index.js.map +1 -1
- package/build-style/footnotes/style-rtl.css +2 -2
- package/build-style/footnotes/style.css +2 -2
- package/build-style/image/style-rtl.css +16 -2
- package/build-style/image/style.css +16 -2
- package/build-style/style-rtl.css +18 -4
- package/build-style/style.css +18 -4
- package/package.json +33 -38
- package/src/archives/block.json +5 -1
- package/src/audio/block.json +5 -1
- package/src/avatar/block.json +1 -1
- package/src/block/edit.js +2 -2
- package/src/block/edit.native.js +8 -12
- package/src/block/test/edit.native.js +4 -4
- package/src/buttons/edit.js +2 -2
- package/src/categories/block.json +5 -1
- package/src/code/block.json +5 -1
- package/src/column/block.json +1 -0
- package/src/comments/block.json +1 -0
- package/src/cover/block.json +1 -0
- package/src/cover/edit/inspector-controls.js +1 -0
- package/src/details/block.json +5 -1
- package/src/embed/util.js +4 -6
- package/src/file/block.json +2 -1
- package/src/file/index.php +0 -17
- package/src/file/view.js +14 -5
- package/src/footnotes/index.php +11 -9
- package/src/footnotes/style.scss +2 -2
- package/src/gallery/block.json +3 -1
- package/src/group/block.json +1 -0
- package/src/heading/block.json +5 -1
- package/src/heading/test/index.native.js +18 -0
- package/src/image/block.json +6 -0
- package/src/image/deprecated.js +597 -320
- package/src/image/edit.js +0 -4
- package/src/image/image.js +131 -62
- package/src/image/save.js +9 -1
- package/src/image/style.scss +15 -2
- package/src/image/utils.js +16 -0
- package/src/image/{interactivity.js → view-interactivity.js} +99 -50
- package/src/index.js +18 -1
- package/src/latest-posts/index.php +1 -1
- package/src/list/block.json +5 -1
- package/src/media-text/block.json +1 -0
- package/src/missing/edit.js +31 -11
- package/src/navigation/block.json +3 -2
- package/src/navigation/edit/index.js +1 -2
- package/src/navigation/edit/menu-inspector-controls.js +0 -1
- package/src/navigation/index.php +39 -30
- package/src/navigation/view.js +189 -67
- package/src/navigation-link/edit.js +1 -15
- package/src/navigation-link/link-ui.js +14 -2
- package/src/navigation-submenu/index.php +2 -12
- package/src/page-list/convert-to-links-modal.js +3 -3
- package/src/page-list/edit.js +65 -62
- package/src/page-list/use-convert-to-navigation-links.js +3 -20
- package/src/paragraph/block.json +1 -0
- package/src/post-comments-form/block.json +1 -0
- package/src/post-navigation-link/block.json +1 -0
- package/src/post-time-to-read/block.json +5 -1
- package/src/query-pagination-numbers/block.json +1 -1
- package/src/quote/block.json +1 -0
- package/src/site-logo/block.json +5 -1
- package/src/site-tagline/block.json +5 -1
- package/src/site-tagline/icon.js +1 -1
- package/src/site-title/block.json +5 -1
- package/src/social-links/block.json +3 -1
- package/src/table/block.json +5 -1
- package/src/term-description/block.json +1 -0
- package/src/verse/block.json +5 -1
- package/src/video/block.json +5 -1
- package/build/file/interactivity.js +0 -19
- package/build/file/interactivity.js.map +0 -1
- package/build/heading/heading-level-icon.js +0 -61
- package/build/heading/heading-level-icon.js.map +0 -1
- package/build/image/interactivity.js.map +0 -1
- package/build/navigation/interactivity.js +0 -167
- package/build/navigation/interactivity.js.map +0 -1
- package/build/navigation/view-modal.js +0 -64
- package/build/navigation/view-modal.js.map +0 -1
- package/build/utils/interactivity/constants.js +0 -9
- package/build/utils/interactivity/constants.js.map +0 -1
- package/build/utils/interactivity/directives.js +0 -222
- package/build/utils/interactivity/directives.js.map +0 -1
- package/build/utils/interactivity/hooks.js +0 -159
- package/build/utils/interactivity/hooks.js.map +0 -1
- package/build/utils/interactivity/hydration.js +0 -34
- package/build/utils/interactivity/hydration.js.map +0 -1
- package/build/utils/interactivity/index.js +0 -32
- package/build/utils/interactivity/index.js.map +0 -1
- package/build/utils/interactivity/portals.js +0 -108
- package/build/utils/interactivity/portals.js.map +0 -1
- package/build/utils/interactivity/store.js +0 -66
- package/build/utils/interactivity/store.js.map +0 -1
- package/build/utils/interactivity/utils.js +0 -87
- package/build/utils/interactivity/utils.js.map +0 -1
- package/build/utils/interactivity/vdom.js +0 -119
- package/build/utils/interactivity/vdom.js.map +0 -1
- package/build-module/file/interactivity.js +0 -15
- package/build-module/file/interactivity.js.map +0 -1
- package/build-module/heading/heading-level-icon.js +0 -53
- package/build-module/heading/heading-level-icon.js.map +0 -1
- package/build-module/image/interactivity.js.map +0 -1
- package/build-module/navigation/interactivity.js +0 -164
- package/build-module/navigation/interactivity.js.map +0 -1
- package/build-module/navigation/view-modal.js +0 -58
- package/build-module/navigation/view-modal.js.map +0 -1
- package/build-module/utils/interactivity/constants.js +0 -2
- package/build-module/utils/interactivity/constants.js.map +0 -1
- package/build-module/utils/interactivity/directives.js +0 -209
- package/build-module/utils/interactivity/directives.js.map +0 -1
- package/build-module/utils/interactivity/hooks.js +0 -145
- package/build-module/utils/interactivity/hooks.js.map +0 -1
- package/build-module/utils/interactivity/hydration.js +0 -21
- package/build-module/utils/interactivity/hydration.js.map +0 -1
- package/build-module/utils/interactivity/index.js +0 -15
- package/build-module/utils/interactivity/index.js.map +0 -1
- package/build-module/utils/interactivity/portals.js +0 -100
- package/build-module/utils/interactivity/portals.js.map +0 -1
- package/build-module/utils/interactivity/store.js +0 -55
- package/build-module/utils/interactivity/store.js.map +0 -1
- package/build-module/utils/interactivity/utils.js +0 -75
- package/build-module/utils/interactivity/utils.js.map +0 -1
- package/build-module/utils/interactivity/vdom.js +0 -107
- package/build-module/utils/interactivity/vdom.js.map +0 -1
- package/src/file/interactivity.js +0 -15
- package/src/heading/heading-level-icon.js +0 -48
- package/src/navigation/interactivity.js +0 -169
- package/src/navigation/view-modal.js +0 -78
- package/src/utils/interactivity/constants.js +0 -1
- package/src/utils/interactivity/directives.js +0 -200
- package/src/utils/interactivity/hooks.js +0 -145
- package/src/utils/interactivity/hydration.js +0 -22
- package/src/utils/interactivity/index.js +0 -15
- package/src/utils/interactivity/portals.js +0 -98
- package/src/utils/interactivity/store.js +0 -45
- package/src/utils/interactivity/utils.js +0 -66
- package/src/utils/interactivity/vdom.js +0 -111
|
@@ -5,16 +5,6 @@
|
|
|
5
5
|
* @package WordPress
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Build an array with CSS classes and inline styles defining the colors
|
|
10
|
-
* which will be applied to the navigation markup in the front-end.
|
|
11
|
-
*
|
|
12
|
-
* @param array $context Navigation block context.
|
|
13
|
-
* @param array $attributes Block attributes.
|
|
14
|
-
* @param bool $is_sub_menu Whether the block is a sub-menu.
|
|
15
|
-
* @return array Colors CSS classes and inline styles.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
8
|
/**
|
|
19
9
|
* Build an array with CSS classes and inline styles defining the font sizes
|
|
20
10
|
* which will be applied to the navigation markup in the front-end.
|
|
@@ -199,9 +189,9 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
|
|
|
199
189
|
$attributes['style']['color']['background'] = $block->context['customOverlayBackgroundColor'];
|
|
200
190
|
}
|
|
201
191
|
|
|
202
|
-
// This allows us to be able to get a response from
|
|
192
|
+
// This allows us to be able to get a response from wp_apply_colors_support.
|
|
203
193
|
$block->block_type->supports['color'] = true;
|
|
204
|
-
$colors_supports =
|
|
194
|
+
$colors_supports = wp_apply_colors_support( $block->block_type, $attributes );
|
|
205
195
|
$css_classes = 'wp-block-navigation__submenu-container';
|
|
206
196
|
if ( array_key_exists( 'class', $colors_supports ) ) {
|
|
207
197
|
$css_classes .= ' ' . $colors_supports['class'];
|
|
@@ -5,14 +5,14 @@ import { Button, Modal } from '@wordpress/components';
|
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
|
|
7
7
|
export const convertDescription = __(
|
|
8
|
-
'This
|
|
8
|
+
'This page list is synced with the published pages on your site. Detach the page list to add, delete, or reorder pages yourself.'
|
|
9
9
|
);
|
|
10
10
|
|
|
11
11
|
export function ConvertToLinksModal( { onClick, onClose, disabled } ) {
|
|
12
12
|
return (
|
|
13
13
|
<Modal
|
|
14
14
|
onRequestClose={ onClose }
|
|
15
|
-
title={ __( 'Edit
|
|
15
|
+
title={ __( 'Edit Page List' ) }
|
|
16
16
|
className={ 'wp-block-page-list-modal' }
|
|
17
17
|
aria={ {
|
|
18
18
|
describedby: 'wp-block-page-list-modal__description',
|
|
@@ -30,7 +30,7 @@ export function ConvertToLinksModal( { onClick, onClose, disabled } ) {
|
|
|
30
30
|
disabled={ disabled }
|
|
31
31
|
onClick={ onClick }
|
|
32
32
|
>
|
|
33
|
-
{ __( '
|
|
33
|
+
{ __( 'Detach' ) }
|
|
34
34
|
</Button>
|
|
35
35
|
</div>
|
|
36
36
|
</Modal>
|
package/src/page-list/edit.js
CHANGED
|
@@ -169,12 +169,6 @@ export default function PageListEdit( {
|
|
|
169
169
|
}, new Map() );
|
|
170
170
|
}, [ pages ] );
|
|
171
171
|
|
|
172
|
-
const convertToNavigationLinks = useConvertToNavigationLinks( {
|
|
173
|
-
clientId,
|
|
174
|
-
pages,
|
|
175
|
-
parentPageID,
|
|
176
|
-
} );
|
|
177
|
-
|
|
178
172
|
const blockProps = useBlockProps( {
|
|
179
173
|
className: classnames( 'wp-block-page-list', {
|
|
180
174
|
'has-text-color': !! context.textColor,
|
|
@@ -189,68 +183,71 @@ export default function PageListEdit( {
|
|
|
189
183
|
style: { ...context.style?.color },
|
|
190
184
|
} );
|
|
191
185
|
|
|
192
|
-
const
|
|
193
|
-
|
|
186
|
+
const pagesTree = useMemo(
|
|
187
|
+
function makePagesTree( parentId = 0, level = 0 ) {
|
|
188
|
+
const childPages = pagesByParentId.get( parentId );
|
|
194
189
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return childPages.reduce( ( template, page ) => {
|
|
200
|
-
const hasChildren = pagesByParentId.has( page.id );
|
|
201
|
-
const pageProps = {
|
|
202
|
-
id: page.id,
|
|
203
|
-
label:
|
|
204
|
-
// translators: displayed when a page has an empty title.
|
|
205
|
-
page.title?.rendered?.trim() !== ''
|
|
206
|
-
? page.title?.rendered
|
|
207
|
-
: __( '(no title)' ),
|
|
208
|
-
title: page.title?.rendered,
|
|
209
|
-
link: page.url,
|
|
210
|
-
hasChildren,
|
|
211
|
-
};
|
|
212
|
-
let item = null;
|
|
213
|
-
const children = getBlockList( page.id );
|
|
214
|
-
item = createBlock( 'core/page-list-item', pageProps, children );
|
|
215
|
-
template.push( item );
|
|
216
|
-
|
|
217
|
-
return template;
|
|
218
|
-
}, [] );
|
|
219
|
-
};
|
|
190
|
+
if ( ! childPages?.length ) {
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
220
193
|
|
|
221
|
-
|
|
222
|
-
|
|
194
|
+
return childPages.reduce( ( tree, page ) => {
|
|
195
|
+
const hasChildren = pagesByParentId.has( page.id );
|
|
196
|
+
const item = {
|
|
197
|
+
value: page.id,
|
|
198
|
+
label: '— '.repeat( level ) + page.title.rendered,
|
|
199
|
+
rawName: page.title.rendered,
|
|
200
|
+
};
|
|
201
|
+
tree.push( item );
|
|
202
|
+
if ( hasChildren ) {
|
|
203
|
+
tree.push( ...makePagesTree( page.id, level + 1 ) );
|
|
204
|
+
}
|
|
205
|
+
return tree;
|
|
206
|
+
}, [] );
|
|
207
|
+
},
|
|
208
|
+
[ pagesByParentId ]
|
|
209
|
+
);
|
|
223
210
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
211
|
+
const blockList = useMemo(
|
|
212
|
+
function getBlockList( parentId = parentPageID ) {
|
|
213
|
+
const childPages = pagesByParentId.get( parentId );
|
|
227
214
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
const item = {
|
|
231
|
-
value: page.id,
|
|
232
|
-
label: '— '.repeat( level ) + page.title.rendered,
|
|
233
|
-
rawName: page.title.rendered,
|
|
234
|
-
};
|
|
235
|
-
tree.push( item );
|
|
236
|
-
if ( hasChildren ) {
|
|
237
|
-
tree.push( ...makePagesTree( page.id, level + 1 ) );
|
|
215
|
+
if ( ! childPages?.length ) {
|
|
216
|
+
return [];
|
|
238
217
|
}
|
|
239
|
-
return tree;
|
|
240
|
-
}, [] );
|
|
241
|
-
};
|
|
242
218
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
219
|
+
return childPages.reduce( ( template, page ) => {
|
|
220
|
+
const hasChildren = pagesByParentId.has( page.id );
|
|
221
|
+
const pageProps = {
|
|
222
|
+
id: page.id,
|
|
223
|
+
label:
|
|
224
|
+
// translators: displayed when a page has an empty title.
|
|
225
|
+
page.title?.rendered?.trim() !== ''
|
|
226
|
+
? page.title?.rendered
|
|
227
|
+
: __( '(no title)' ),
|
|
228
|
+
title: page.title?.rendered,
|
|
229
|
+
link: page.url,
|
|
230
|
+
hasChildren,
|
|
231
|
+
};
|
|
232
|
+
let item = null;
|
|
233
|
+
const children = getBlockList( page.id );
|
|
234
|
+
item = createBlock(
|
|
235
|
+
'core/page-list-item',
|
|
236
|
+
pageProps,
|
|
237
|
+
children
|
|
238
|
+
);
|
|
239
|
+
template.push( item );
|
|
240
|
+
|
|
241
|
+
return template;
|
|
242
|
+
}, [] );
|
|
243
|
+
},
|
|
244
|
+
[ pagesByParentId, parentPageID ]
|
|
245
|
+
);
|
|
249
246
|
|
|
250
247
|
const {
|
|
251
248
|
isNested,
|
|
252
249
|
hasSelectedChild,
|
|
253
|
-
|
|
250
|
+
parentClientId,
|
|
254
251
|
hasDraggedChild,
|
|
255
252
|
isChildOfNavigation,
|
|
256
253
|
} = useSelect(
|
|
@@ -258,7 +255,6 @@ export default function PageListEdit( {
|
|
|
258
255
|
const {
|
|
259
256
|
getBlockParentsByBlockName,
|
|
260
257
|
hasSelectedInnerBlock,
|
|
261
|
-
getBlockRootClientId,
|
|
262
258
|
hasDraggedInnerBlock,
|
|
263
259
|
} = select( blockEditorStore );
|
|
264
260
|
const blockParents = getBlockParentsByBlockName(
|
|
@@ -276,12 +272,19 @@ export default function PageListEdit( {
|
|
|
276
272
|
isChildOfNavigation: navigationBlockParents.length > 0,
|
|
277
273
|
hasSelectedChild: hasSelectedInnerBlock( clientId, true ),
|
|
278
274
|
hasDraggedChild: hasDraggedInnerBlock( clientId, true ),
|
|
279
|
-
|
|
275
|
+
parentClientId: navigationBlockParents[ 0 ],
|
|
280
276
|
};
|
|
281
277
|
},
|
|
282
278
|
[ clientId ]
|
|
283
279
|
);
|
|
284
280
|
|
|
281
|
+
const convertToNavigationLinks = useConvertToNavigationLinks( {
|
|
282
|
+
clientId,
|
|
283
|
+
pages,
|
|
284
|
+
parentClientId,
|
|
285
|
+
parentPageID,
|
|
286
|
+
} );
|
|
287
|
+
|
|
285
288
|
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
286
289
|
allowedBlocks: [ 'core/page-list-item' ],
|
|
287
290
|
renderAppender: false,
|
|
@@ -297,12 +300,12 @@ export default function PageListEdit( {
|
|
|
297
300
|
useEffect( () => {
|
|
298
301
|
if ( hasSelectedChild || hasDraggedChild ) {
|
|
299
302
|
openModal();
|
|
300
|
-
selectBlock(
|
|
303
|
+
selectBlock( parentClientId );
|
|
301
304
|
}
|
|
302
305
|
}, [
|
|
303
306
|
hasSelectedChild,
|
|
304
307
|
hasDraggedChild,
|
|
305
|
-
|
|
308
|
+
parentClientId,
|
|
306
309
|
selectBlock,
|
|
307
310
|
openModal,
|
|
308
311
|
] );
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { createBlock } from '@wordpress/blocks';
|
|
5
|
-
import {
|
|
5
|
+
import { useDispatch } from '@wordpress/data';
|
|
6
6
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -116,28 +116,11 @@ export function convertToNavigationLinks( pages = [], parentPageID = null ) {
|
|
|
116
116
|
export function useConvertToNavigationLinks( {
|
|
117
117
|
clientId,
|
|
118
118
|
pages,
|
|
119
|
+
parentClientId,
|
|
119
120
|
parentPageID,
|
|
120
121
|
} ) {
|
|
121
122
|
const { replaceBlock, selectBlock } = useDispatch( blockEditorStore );
|
|
122
123
|
|
|
123
|
-
const { parentNavBlockClientId } = useSelect(
|
|
124
|
-
( select ) => {
|
|
125
|
-
const { getSelectedBlockClientId, getBlockParentsByBlockName } =
|
|
126
|
-
select( blockEditorStore );
|
|
127
|
-
|
|
128
|
-
const _selectedBlockClientId = getSelectedBlockClientId();
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
parentNavBlockClientId: getBlockParentsByBlockName(
|
|
132
|
-
_selectedBlockClientId,
|
|
133
|
-
'core/navigation',
|
|
134
|
-
true
|
|
135
|
-
)[ 0 ],
|
|
136
|
-
};
|
|
137
|
-
},
|
|
138
|
-
[ clientId ]
|
|
139
|
-
);
|
|
140
|
-
|
|
141
124
|
return () => {
|
|
142
125
|
const navigationLinks = convertToNavigationLinks( pages, parentPageID );
|
|
143
126
|
|
|
@@ -145,6 +128,6 @@ export function useConvertToNavigationLinks( {
|
|
|
145
128
|
replaceBlock( clientId, navigationLinks );
|
|
146
129
|
|
|
147
130
|
// Select the Navigation block to reveal the changes.
|
|
148
|
-
selectBlock(
|
|
131
|
+
selectBlock( parentClientId );
|
|
149
132
|
};
|
|
150
133
|
}
|
package/src/paragraph/block.json
CHANGED
package/src/quote/block.json
CHANGED
package/src/site-logo/block.json
CHANGED
package/src/site-tagline/icon.js
CHANGED
package/src/table/block.json
CHANGED
package/src/verse/block.json
CHANGED
package/src/video/block.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interactivity = require("../utils/interactivity");
|
|
4
|
-
|
|
5
|
-
var _utils = require("./utils");
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
(0, _interactivity.store)({
|
|
11
|
-
selectors: {
|
|
12
|
-
core: {
|
|
13
|
-
file: {
|
|
14
|
-
hasPdfPreview: _utils.browserSupportsPdfs
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
//# sourceMappingURL=interactivity.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/file/interactivity.js"],"names":["selectors","core","file","hasPdfPreview"],"mappings":";;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,0BAAO;AACNA,EAAAA,SAAS,EAAE;AACVC,IAAAA,IAAI,EAAE;AACLC,MAAAA,IAAI,EAAE;AACLC,QAAAA,aAAa,EAAbA;AADK;AADD;AADI;AADL,CAAP","sourcesContent":["/**\n * Internal dependencies\n */\nimport { store } from '../utils/interactivity';\nimport { browserSupportsPdfs as hasPdfPreview } from './utils';\n\nstore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tfile: {\n\t\t\t\thasPdfPreview,\n\t\t\t},\n\t\t},\n\t},\n} );\n"]}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = HeadingLevelIcon;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
var _components = require("@wordpress/components");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* WordPress dependencies
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/** @typedef {import('@wordpress/element').WPComponent} WPComponent */
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* HeadingLevelIcon props.
|
|
20
|
-
*
|
|
21
|
-
* @typedef WPHeadingLevelIconProps
|
|
22
|
-
*
|
|
23
|
-
* @property {number} level The heading level to show an icon for.
|
|
24
|
-
* @property {?boolean} isPressed Whether or not the icon should appear pressed; default: false.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Heading level icon.
|
|
29
|
-
*
|
|
30
|
-
* @param {WPHeadingLevelIconProps} props Component props.
|
|
31
|
-
*
|
|
32
|
-
* @return {?WPComponent} The icon.
|
|
33
|
-
*/
|
|
34
|
-
function HeadingLevelIcon({
|
|
35
|
-
level,
|
|
36
|
-
isPressed = false
|
|
37
|
-
}) {
|
|
38
|
-
const levelToPath = {
|
|
39
|
-
1: 'M9 5h2v10H9v-4H5v4H3V5h2v4h4V5zm6.6 0c-.6.9-1.5 1.7-2.6 2v1h2v7h2V5h-1.4z',
|
|
40
|
-
2: 'M7 5h2v10H7v-4H3v4H1V5h2v4h4V5zm8 8c.5-.4.6-.6 1.1-1.1.4-.4.8-.8 1.2-1.3.3-.4.6-.8.9-1.3.2-.4.3-.8.3-1.3 0-.4-.1-.9-.3-1.3-.2-.4-.4-.7-.8-1-.3-.3-.7-.5-1.2-.6-.5-.2-1-.2-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, _element.createElement)(_components.SVG, {
|
|
52
|
-
width: "24",
|
|
53
|
-
height: "24",
|
|
54
|
-
viewBox: "0 0 20 20",
|
|
55
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
56
|
-
isPressed: isPressed
|
|
57
|
-
}, (0, _element.createElement)(_components.Path, {
|
|
58
|
-
d: levelToPath[level]
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=heading-level-icon.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/heading/heading-level-icon.js"],"names":["HeadingLevelIcon","level","isPressed","levelToPath","hasOwnProperty"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,gBAAT,CAA2B;AAAEC,EAAAA,KAAF;AAASC,EAAAA,SAAS,GAAG;AAArB,CAA3B,EAA0D;AACxE,QAAMC,WAAW,GAAG;AACnB,OAAG,2EADgB;AAEnB,OAAG,sYAFgB;AAGnB,OAAG,+iBAHgB;AAInB,OAAG,uFAJgB;AAKnB,OAAG,0ZALgB;AAMnB,OAAG;AANgB,GAApB;;AAQA,MAAK,CAAEA,WAAW,CAACC,cAAZ,CAA4BH,KAA5B,CAAP,EAA6C;AAC5C,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,eAAD;AACC,IAAA,KAAK,EAAC,IADP;AAEC,IAAA,MAAM,EAAC,IAFR;AAGC,IAAA,OAAO,EAAC,WAHT;AAIC,IAAA,KAAK,EAAC,4BAJP;AAKC,IAAA,SAAS,EAAGC;AALb,KAOC,4BAAC,gBAAD;AAAM,IAAA,CAAC,EAAGC,WAAW,CAAEF,KAAF;AAArB,IAPD,CADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Path, SVG } from '@wordpress/components';\n\n/** @typedef {import('@wordpress/element').WPComponent} WPComponent */\n\n/**\n * HeadingLevelIcon props.\n *\n * @typedef WPHeadingLevelIconProps\n *\n * @property {number} level The heading level to show an icon for.\n * @property {?boolean} isPressed Whether or not the icon should appear pressed; default: false.\n */\n\n/**\n * Heading level icon.\n *\n * @param {WPHeadingLevelIconProps} props Component props.\n *\n * @return {?WPComponent} The icon.\n */\nexport default function HeadingLevelIcon( { level, isPressed = false } ) {\n\tconst levelToPath = {\n\t\t1: 'M9 5h2v10H9v-4H5v4H3V5h2v4h4V5zm6.6 0c-.6.9-1.5 1.7-2.6 2v1h2v7h2V5h-1.4z',\n\t\t2: 'M7 5h2v10H7v-4H3v4H1V5h2v4h4V5zm8 8c.5-.4.6-.6 1.1-1.1.4-.4.8-.8 1.2-1.3.3-.4.6-.8.9-1.3.2-.4.3-.8.3-1.3 0-.4-.1-.9-.3-1.3-.2-.4-.4-.7-.8-1-.3-.3-.7-.5-1.2-.6-.5-.2-1-.2-1.5-.2-.4 0-.7 0-1.1.1-.3.1-.7.2-1 .3-.3.1-.6.3-.9.5-.3.2-.6.4-.8.7l1.2 1.2c.3-.3.6-.5 1-.7.4-.2.7-.3 1.2-.3s.9.1 1.3.4c.3.3.5.7.5 1.1 0 .4-.1.8-.4 1.1-.3.5-.6.9-1 1.2-.4.4-1 .9-1.6 1.4-.6.5-1.4 1.1-2.2 1.6V15h8v-2H15z',\n\t\t3: 'M12.1 12.2c.4.3.8.5 1.2.7.4.2.9.3 1.4.3.5 0 1-.1 1.4-.3.3-.1.5-.5.5-.8 0-.2 0-.4-.1-.6-.1-.2-.3-.3-.5-.4-.3-.1-.7-.2-1-.3-.5-.1-1-.1-1.5-.1V9.1c.7.1 1.5-.1 2.2-.4.4-.2.6-.5.6-.9 0-.3-.1-.6-.4-.8-.3-.2-.7-.3-1.1-.3-.4 0-.8.1-1.1.3-.4.2-.7.4-1.1.6l-1.2-1.4c.5-.4 1.1-.7 1.6-.9.5-.2 1.2-.3 1.8-.3.5 0 1 .1 1.6.2.4.1.8.3 1.2.5.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.4-.9-.4-.4-.8-.9-1-1.5-.2-.6-.3-1.3-.3-2.1s.1-1.6.4-2.3c.2-.6.6-1.2 1-1.6.4-.4.9-.7 1.4-.9.6-.3 1.1-.4 1.7-.4.7 0 1.4.1 2 .3.5.2 1 .5 1.4.8 0 .1-1.3 1.4-1.3 1.4zm-2.4 5.8c.2 0 .4 0 .6-.1.2 0 .4-.1.5-.2.1-.1.3-.3.4-.5.1-.2.1-.5.1-.7 0-.4-.1-.8-.4-1.1-.3-.2-.7-.3-1.1-.3-.3 0-.7.1-1 .2-.4.2-.7.4-1 .7 0 .3.1.7.3 1 .1.2.3.4.4.6.2.1.3.3.5.3.2.1.5.2.7.1z',\n\t};\n\tif ( ! levelToPath.hasOwnProperty( level ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SVG\n\t\t\twidth=\"24\"\n\t\t\theight=\"24\"\n\t\t\tviewBox=\"0 0 20 20\"\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\tisPressed={ isPressed }\n\t\t>\n\t\t\t<Path d={ levelToPath[ level ] } />\n\t\t</SVG>\n\t);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/image/interactivity.js"],"names":["focusableSelectors","actions","core","image","showLightbox","context","event","initialized","lastFocusedElement","window","document","activeElement","scrollDelta","imgDom","createElement","onload","lightboxEnabled","lightboxAnimation","setZoomStyles","documentElement","classList","add","setAttribute","imageSrc","hideLightbox","hideAnimationEnabled","deltaY","type","Math","abs","scrollY","scrollTop","pageYOffset","scrollLeft","pageXOffset","onscroll","scrollTo","setTimeout","remove","focus","handleKeydown","key","keyCode","shiftKey","firstFocusableElement","preventDefault","lastFocusableElement","selectors","roleAttribute","effects","initLightbox","ref","figureRef","querySelector","imageRef","focusableElements","querySelectorAll","length","targetWidth","naturalWidth","targetHeight","naturalHeight","verticalPadding","containerWidth","clientWidth","horizontalPadding","containerHeight","clientHeight","widthOverflow","min","heightOverflow","x","originLeft","y","originTop","target","nextElementSibling","getBoundingClientRect","scaleWidth","offsetWidth","scaleHeight","offsetHeight","targetLeft","targetTop","root","style","setProperty"],"mappings":";;AAGA;;AAHA;AACA;AACA;AAGA,MAAMA,kBAAkB,GAAG,CAC1B,SAD0B,EAE1B,YAF0B,EAG1B,+DAH0B,EAI1B,2CAJ0B,EAK1B,6CAL0B,EAM1B,2CAN0B,EAO1B,QAP0B,EAQ1B,QAR0B,EAS1B,OAT0B,EAU1B,mBAV0B,EAW1B,iCAX0B,CAA3B;AAcA,0BAAO;AACNC,EAAAA,OAAO,EAAE;AACRC,IAAAA,IAAI,EAAE;AACLC,MAAAA,KAAK,EAAE;AACNC,QAAAA,YAAY,EAAE,CAAE;AAAEC,UAAAA,OAAF;AAAWC,UAAAA;AAAX,SAAF,KAA0B;AACvCD,UAAAA,OAAO,CAACH,IAAR,CAAaC,KAAb,CAAmBI,WAAnB,GAAiC,IAAjC;AACAF,UAAAA,OAAO,CAACH,IAAR,CAAaC,KAAb,CAAmBK,kBAAnB,GACCC,MAAM,CAACC,QAAP,CAAgBC,aADjB;AAEAN,UAAAA,OAAO,CAACH,IAAR,CAAaC,KAAb,CAAmBS,WAAnB,GAAiC,CAAjC,CAJuC,CAMvC;AACA;AACA;;AACA,gBAAMC,MAAM,GAAGH,QAAQ,CAACI,aAAT,CAAwB,KAAxB,CAAf;;AAEAD,UAAAA,MAAM,CAACE,MAAP,GAAgB,YAAY;AAC3B;AACA;AACAV,YAAAA,OAAO,CAACH,IAAR,CAAaC,KAAb,CAAmBa,eAAnB,GAAqC,IAArC;;AACA,gBAAKX,OAAO,CAACH,IAAR,CAAaC,KAAb,CAAmBc,iBAAnB,KAAyC,MAA9C,EAAuD;AACtDC,cAAAA,aAAa,CAAEL,MAAF,EAAUR,OAAV,EAAmBC,KAAnB,CAAb;AACA,aAN0B,CAQ3B;AACA;AACA;;;AACAI,YAAAA,QAAQ,CAACS,eAAT,CAAyBC,SAAzB,CAAmCC,GA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AQ,CAACS,eAAtB;AACAiE,EAAAA,IAAI,CAACC,KAAL,CAAWC,WAAX,CAAwB,wBAAxB,EAAkDR,UAAlD;AACAM,EAAAA,IAAI,CAACC,KAAL,CAAWC,WAAX,CAAwB,yBAAxB,EAAmDN,WAAnD;AACAI,EAAAA,IAAI,CAACC,KAAL,CAAWC,WAAX,CAAwB,4BAAxB,EAAsD5B,WAAW,GAAG,IAApE;AACA0B,EAAAA,IAAI,CAACC,KAAL,CAAWC,WAAX,CACC,6BADD,EAEC1B,YAAY,GAAG,IAFhB;AAIAwB,EAAAA,IAAI,CAACC,KAAL,CAAWC,WAAX,CACC,kCADD,EAECd,UAAU,GAAG,IAFd;AAIAY,EAAAA,IAAI,CAACC,KAAL,CAAWC,WAAX,CACC,iCADD,EAECZ,SAAS,GAAG,IAFb;AAIAU,EAAAA,IAAI,CAACC,KAAL,CAAWC,WAAX,CACC,iCADD,EAECJ,UAAU,GAAG,IAFd;AAIAE,EAAAA,IAAI,CAACC,KAAL,CAAWC,WAAX,CACC,gCADD,EAECH,SAAS,GAAG,IAFb;AAIA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { store } from '../utils/interactivity';\n\nconst focusableSelectors = [\n\t'a[href]',\n\t'area[href]',\n\t'input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden])',\n\t'select:not([disabled]):not([aria-hidden])',\n\t'textarea:not([disabled]):not([aria-hidden])',\n\t'button:not([disabled]):not([aria-hidden])',\n\t'iframe',\n\t'object',\n\t'embed',\n\t'[contenteditable]',\n\t'[tabindex]:not([tabindex^=\"-\"])',\n];\n\nstore( {\n\tactions: {\n\t\tcore: {\n\t\t\timage: {\n\t\t\t\tshowLightbox: ( { context, event } ) => {\n\t\t\t\t\tcontext.core.image.initialized = true;\n\t\t\t\t\tcontext.core.image.lastFocusedElement =\n\t\t\t\t\t\twindow.document.activeElement;\n\t\t\t\t\tcontext.core.image.scrollDelta = 0;\n\n\t\t\t\t\t// Since the img is hidden and its src not loaded until\n\t\t\t\t\t// the lightbox is opened, let's create an img element on the fly\n\t\t\t\t\t// so we can get the dimensions we need to calculate the styles\n\t\t\t\t\tconst imgDom = document.createElement( 'img' );\n\n\t\t\t\t\timgDom.onload = function () {\n\t\t\t\t\t\t// Enable the lightbox only after the image\n\t\t\t\t\t\t// is loaded to prevent flashing of unstyled content\n\t\t\t\t\t\tcontext.core.image.lightboxEnabled = true;\n\t\t\t\t\t\tif ( context.core.image.lightboxAnimation === 'zoom' ) {\n\t\t\t\t\t\t\tsetZoomStyles( imgDom, context, event );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Hide overflow only when the animation is in progress,\n\t\t\t\t\t\t// otherwise the removal of the scrollbars will draw attention\n\t\t\t\t\t\t// to itself and look like an error\n\t\t\t\t\t\tdocument.documentElement.classList.add(\n\t\t\t\t\t\t\t'has-lightbox-open'\n\t\t\t\t\t\t);\n\t\t\t\t\t};\n\t\t\t\t\timgDom.setAttribute( 'src', context.core.image.imageSrc );\n\t\t\t\t},\n\t\t\t\thideLightbox: async ( { context, event } ) => {\n\t\t\t\t\tcontext.core.image.hideAnimationEnabled = true;\n\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\t// If scrolling, wait a moment before closing the lightbox.\n\t\t\t\t\t\tif ( context.core.image.lightboxAnimation === 'fade' ) {\n\t\t\t\t\t\t\tcontext.core.image.scrollDelta += event.deltaY;\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tevent.type === 'mousewheel' &&\n\t\t\t\t\t\t\t\tMath.abs(\n\t\t\t\t\t\t\t\t\twindow.scrollY -\n\t\t\t\t\t\t\t\t\t\tcontext.core.image.scrollDelta\n\t\t\t\t\t\t\t\t) < 10\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\tcontext.core.image.lightboxAnimation === 'zoom'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// Disable scroll until the zoom animation ends.\n\t\t\t\t\t\t\t// Get the current page scroll position\n\t\t\t\t\t\t\tconst scrollTop =\n\t\t\t\t\t\t\t\twindow.pageYOffset ||\n\t\t\t\t\t\t\t\tdocument.documentElement.scrollTop;\n\t\t\t\t\t\t\tconst scrollLeft =\n\t\t\t\t\t\t\t\twindow.pageXOffset ||\n\t\t\t\t\t\t\t\tdocument.documentElement.scrollLeft;\n\t\t\t\t\t\t\t// if any scroll is attempted, set this to the previous value.\n\t\t\t\t\t\t\twindow.onscroll = function () {\n\t\t\t\t\t\t\t\twindow.scrollTo( scrollLeft, scrollTop );\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t// Enable scrolling after the animation finishes\n\t\t\t\t\t\t\tsetTimeout( function () {\n\t\t\t\t\t\t\t\twindow.onscroll = function () {};\n\t\t\t\t\t\t\t}, 400 );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tdocument.documentElement.classList.remove(\n\t\t\t\t\t\t\t'has-lightbox-open'\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tcontext.core.image.lightboxEnabled = false;\n\t\t\t\t\t\tcontext.core.image.lastFocusedElement.focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thandleKeydown: ( { context, actions, event } ) => {\n\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\tif ( event.key === 'Tab' || event.keyCode === 9 ) {\n\t\t\t\t\t\t\t// If shift + tab it change the direction\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.image.firstFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.image.lastFocusableElement.focus();\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.image.lastFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.image.firstFocusableElement.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( event.key === 'Escape' || event.keyCode === 27 ) {\n\t\t\t\t\t\t\tactions.core.image.hideLightbox( {\n\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\tselectors: {\n\t\tcore: {\n\t\t\timage: {\n\t\t\t\troleAttribute: ( { context } ) => {\n\t\t\t\t\treturn context.core.image.lightboxEnabled ? 'dialog' : '';\n\t\t\t\t},\n\t\t\t\timageSrc: ( { context } ) => {\n\t\t\t\t\treturn context.core.image.initialized\n\t\t\t\t\t\t? context.core.image.imageSrc\n\t\t\t\t\t\t: '';\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\teffects: {\n\t\tcore: {\n\t\t\timage: {\n\t\t\t\tinitLightbox: async ( { context, ref } ) => {\n\t\t\t\t\tcontext.core.image.figureRef =\n\t\t\t\t\t\tref.querySelector( 'figure' );\n\t\t\t\t\tcontext.core.image.imageRef = ref.querySelector( 'img' );\n\t\t\t\t\tif ( context.core.image.lightboxEnabled ) {\n\t\t\t\t\t\tconst focusableElements =\n\t\t\t\t\t\t\tref.querySelectorAll( focusableSelectors );\n\t\t\t\t\t\tcontext.core.image.firstFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ 0 ];\n\t\t\t\t\t\tcontext.core.image.lastFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ focusableElements.length - 1 ];\n\n\t\t\t\t\t\tref.querySelector( '.close-button' ).focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n\nfunction setZoomStyles( imgDom, context, event ) {\n\tlet targetWidth = imgDom.naturalWidth;\n\tlet targetHeight = imgDom.naturalHeight;\n\n\tconst verticalPadding = 40;\n\n\t// As per the design, let's allow the image to stretch\n\t// to the full width of its containing figure, but for the height,\n\t// constrain it with a fixed padding\n\tconst containerWidth = context.core.image.figureRef.clientWidth;\n\n\t// The lightbox image has `positione:absolute` and\n\t// ignores its parent's padding, so let's set the padding here,\n\t// to be used when calculating the image width and positioning\n\tlet horizontalPadding = 0;\n\tif ( containerWidth > 480 ) {\n\t\thorizontalPadding = 40;\n\t} else if ( containerWidth > 1920 ) {\n\t\thorizontalPadding = 80;\n\t}\n\n\tconst containerHeight =\n\t\tcontext.core.image.figureRef.clientHeight - verticalPadding * 2;\n\n\t// Check difference between the image and figure dimensions\n\tconst widthOverflow = Math.abs(\n\t\tMath.min( containerWidth - targetWidth, 0 )\n\t);\n\tconst heightOverflow = Math.abs(\n\t\tMath.min( containerHeight - targetHeight, 0 )\n\t);\n\n\t// If image is larger than its container any dimension, resize along its largest axis.\n\t// For vertically oriented devices, always maximize the width.\n\tif ( widthOverflow > 0 || heightOverflow > 0 ) {\n\t\tif (\n\t\t\twidthOverflow >= heightOverflow ||\n\t\t\tcontainerHeight >= containerWidth\n\t\t) {\n\t\t\ttargetWidth = containerWidth - horizontalPadding * 2;\n\t\t\ttargetHeight =\n\t\t\t\timgDom.naturalHeight * ( targetWidth / imgDom.naturalWidth );\n\t\t} else {\n\t\t\ttargetHeight = containerHeight;\n\t\t\ttargetWidth =\n\t\t\t\timgDom.naturalWidth * ( targetHeight / imgDom.naturalHeight );\n\t\t}\n\t}\n\n\t// The reference img element lies adjacent to the event target button in the DOM\n\tconst { x: originLeft, y: originTop } =\n\t\tevent.target.nextElementSibling.getBoundingClientRect();\n\tconst scaleWidth =\n\t\tevent.target.nextElementSibling.offsetWidth / targetWidth;\n\tconst scaleHeight =\n\t\tevent.target.nextElementSibling.offsetHeight / targetHeight;\n\n\t// Get values used to center the image\n\tlet targetLeft = 0;\n\tif ( targetWidth >= containerWidth ) {\n\t\ttargetLeft = horizontalPadding;\n\t} else {\n\t\ttargetLeft = ( containerWidth - targetWidth ) / 2;\n\t}\n\tlet targetTop = 0;\n\tif ( targetHeight >= containerHeight ) {\n\t\ttargetTop = verticalPadding;\n\t} else {\n\t\ttargetTop = ( containerHeight - targetHeight ) / 2 + verticalPadding;\n\t}\n\n\tconst root = document.documentElement;\n\troot.style.setProperty( '--lightbox-scale-width', scaleWidth );\n\troot.style.setProperty( '--lightbox-scale-height', scaleHeight );\n\troot.style.setProperty( '--lightbox-image-max-width', targetWidth + 'px' );\n\troot.style.setProperty(\n\t\t'--lightbox-image-max-height',\n\t\ttargetHeight + 'px'\n\t);\n\troot.style.setProperty(\n\t\t'--lightbox-initial-left-position',\n\t\toriginLeft + 'px'\n\t);\n\troot.style.setProperty(\n\t\t'--lightbox-initial-top-position',\n\t\toriginTop + 'px'\n\t);\n\troot.style.setProperty(\n\t\t'--lightbox-target-left-position',\n\t\ttargetLeft + 'px'\n\t);\n\troot.style.setProperty(\n\t\t'--lightbox-target-top-position',\n\t\ttargetTop + 'px'\n\t);\n}\n"]}
|