@wordpress/block-library 6.0.12 → 6.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/group/edit.native.js +1 -1
- package/build/group/edit.native.js.map +1 -1
- package/build/group/index.js +3 -1
- package/build/group/index.js.map +1 -1
- package/build/image/image.js +30 -6
- package/build/image/image.js.map +1 -1
- package/build/navigation/deprecated.js +1 -3
- package/build/navigation/deprecated.js.map +1 -1
- package/build/navigation/edit/index.js +109 -43
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +10 -3
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +15 -7
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +9 -7
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +3 -11
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-navigation-notice.js +54 -0
- package/build/navigation/edit/use-navigation-notice.js.map +1 -0
- package/build/navigation/index.js +1 -2
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/menu-items-to-blocks.js +4 -1
- package/build/navigation/menu-items-to-blocks.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +9 -2
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation/view.js +14 -9
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-submenu/edit.js +1 -1
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/post-comments/index.js +1 -1
- package/build/post-template/edit.js +54 -13
- package/build/post-template/edit.js.map +1 -1
- package/build/site-logo/edit.js +9 -6
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-logo/index.js +0 -3
- package/build/site-logo/index.js.map +1 -1
- package/build/template-part/edit/index.js +7 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build-module/group/edit.native.js +1 -1
- package/build-module/group/edit.native.js.map +1 -1
- package/build-module/group/index.js +3 -1
- package/build-module/group/index.js.map +1 -1
- package/build-module/image/image.js +31 -7
- package/build-module/image/image.js.map +1 -1
- package/build-module/navigation/deprecated.js +1 -3
- package/build-module/navigation/deprecated.js.map +1 -1
- package/build-module/navigation/edit/index.js +107 -44
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +9 -3
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +15 -7
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +9 -7
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +4 -13
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-navigation-notice.js +44 -0
- package/build-module/navigation/edit/use-navigation-notice.js.map +1 -0
- package/build-module/navigation/index.js +1 -2
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/menu-items-to-blocks.js +3 -1
- package/build-module/navigation/menu-items-to-blocks.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +9 -2
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation/view.js +14 -9
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +1 -1
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/post-comments/index.js +1 -1
- package/build-module/post-template/edit.js +54 -15
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +9 -6
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-logo/index.js +0 -3
- package/build-module/site-logo/index.js.map +1 -1
- package/build-module/template-part/edit/index.js +6 -1
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-style/common-rtl.css +10 -0
- package/build-style/common.css +10 -0
- package/build-style/editor-rtl.css +38 -11
- package/build-style/editor.css +38 -11
- package/build-style/image/editor-rtl.css +16 -0
- package/build-style/image/editor.css +16 -0
- package/build-style/navigation/editor-rtl.css +11 -0
- package/build-style/navigation/editor.css +11 -0
- package/build-style/navigation/style-rtl.css +56 -24
- package/build-style/navigation/style.css +56 -24
- package/build-style/post-comments/style-rtl.css +3 -1
- package/build-style/post-comments/style.css +3 -1
- package/build-style/post-comments-form/style-rtl.css +2 -2
- package/build-style/post-comments-form/style.css +2 -2
- package/build-style/site-logo/editor-rtl.css +1 -11
- package/build-style/site-logo/editor.css +1 -11
- package/build-style/site-logo/style-rtl.css +3 -1
- package/build-style/site-logo/style.css +3 -1
- package/build-style/style-rtl.css +74 -28
- package/build-style/style.css +74 -28
- package/package.json +14 -14
- package/src/common.scss +12 -0
- package/src/editor.scss +12 -0
- package/src/gallery/index.php +7 -8
- package/src/group/block.json +3 -1
- package/src/group/edit.native.js +1 -1
- package/src/home-link/index.php +1 -1
- package/src/image/editor.scss +18 -0
- package/src/image/image.js +32 -8
- package/src/image/index.php +1 -1
- package/src/navigation/block.json +1 -2
- package/src/navigation/deprecated.js +0 -2
- package/src/navigation/edit/index.js +166 -60
- package/src/navigation/edit/navigation-menu-selector.js +20 -6
- package/src/navigation/edit/placeholder/index.js +40 -24
- package/src/navigation/edit/responsive-wrapper.js +10 -7
- package/src/navigation/edit/unsaved-inner-blocks.js +13 -25
- package/src/navigation/edit/use-navigation-notice.js +37 -0
- package/src/navigation/editor.scss +14 -0
- package/src/navigation/index.php +19 -8
- package/src/navigation/menu-items-to-blocks.js +7 -1
- package/src/navigation/style.scss +82 -32
- package/src/navigation/use-navigation-menu.js +20 -0
- package/src/navigation/view.js +15 -9
- package/src/navigation-link/index.php +1 -1
- package/src/navigation-submenu/edit.js +1 -1
- package/src/navigation-submenu/index.php +9 -3
- package/src/page-list/index.php +9 -4
- package/src/post-comments/block.json +5 -1
- package/src/post-comments/index.php +17 -0
- package/src/post-comments/style.scss +7 -3
- package/src/post-comments-form/index.php +6 -4
- package/src/post-comments-form/style.scss +7 -5
- package/src/post-template/edit.js +54 -17
- package/src/site-logo/block.json +0 -3
- package/src/site-logo/edit.js +6 -5
- package/src/site-logo/editor.scss +1 -15
- package/src/site-logo/index.php +0 -4
- package/src/site-logo/style.scss +3 -1
- package/src/template-part/edit/index.js +6 -1
- package/src/template-part/index.php +5 -2
|
@@ -6,12 +6,12 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { memo, useMemo, useState } from '@wordpress/element';
|
|
10
10
|
import { useSelect } from '@wordpress/data';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
import {
|
|
13
13
|
BlockContextProvider,
|
|
14
|
-
|
|
14
|
+
__experimentalUseBlockPreview as useBlockPreview,
|
|
15
15
|
useBlockProps,
|
|
16
16
|
useInnerBlocksProps,
|
|
17
17
|
store as blockEditorStore,
|
|
@@ -30,6 +30,39 @@ function PostTemplateInnerBlocks() {
|
|
|
30
30
|
return <li { ...innerBlocksProps } />;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
function PostTemplateBlockPreview( {
|
|
34
|
+
blocks,
|
|
35
|
+
blockContextId,
|
|
36
|
+
isHidden,
|
|
37
|
+
setActiveBlockContextId,
|
|
38
|
+
} ) {
|
|
39
|
+
const blockPreviewProps = useBlockPreview( {
|
|
40
|
+
blocks,
|
|
41
|
+
} );
|
|
42
|
+
|
|
43
|
+
const handleOnClick = () => {
|
|
44
|
+
setActiveBlockContextId( blockContextId );
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const style = {
|
|
48
|
+
display: isHidden ? 'none' : undefined,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<li
|
|
53
|
+
{ ...blockPreviewProps }
|
|
54
|
+
tabIndex={ 0 }
|
|
55
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
56
|
+
role="button"
|
|
57
|
+
onClick={ handleOnClick }
|
|
58
|
+
onKeyPress={ handleOnClick }
|
|
59
|
+
style={ style }
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const MemoizedPostTemplateBlockPreview = memo( PostTemplateBlockPreview );
|
|
65
|
+
|
|
33
66
|
export default function PostTemplateEdit( {
|
|
34
67
|
clientId,
|
|
35
68
|
context: {
|
|
@@ -53,7 +86,7 @@ export default function PostTemplateEdit( {
|
|
|
53
86
|
},
|
|
54
87
|
} ) {
|
|
55
88
|
const [ { page } ] = queryContext;
|
|
56
|
-
const [
|
|
89
|
+
const [ activeBlockContextId, setActiveBlockContextId ] = useState();
|
|
57
90
|
|
|
58
91
|
const { posts, blocks } = useSelect(
|
|
59
92
|
( select ) => {
|
|
@@ -115,7 +148,6 @@ export default function PostTemplateEdit( {
|
|
|
115
148
|
templateSlug,
|
|
116
149
|
]
|
|
117
150
|
);
|
|
118
|
-
|
|
119
151
|
const blockContexts = useMemo(
|
|
120
152
|
() =>
|
|
121
153
|
posts?.map( ( post ) => ( {
|
|
@@ -144,6 +176,10 @@ export default function PostTemplateEdit( {
|
|
|
144
176
|
return <p { ...blockProps }> { __( 'No results found.' ) }</p>;
|
|
145
177
|
}
|
|
146
178
|
|
|
179
|
+
// To avoid flicker when switching active block contexts, a preview is rendered
|
|
180
|
+
// for each block context, but the preview for the active block context is hidden.
|
|
181
|
+
// This ensures that when it is displayed again, the cached rendering of the
|
|
182
|
+
// block preview is used, instead of having to re-render the preview from scratch.
|
|
147
183
|
return (
|
|
148
184
|
<ul { ...blockProps }>
|
|
149
185
|
{ blockContexts &&
|
|
@@ -152,20 +188,21 @@ export default function PostTemplateEdit( {
|
|
|
152
188
|
key={ blockContext.postId }
|
|
153
189
|
value={ blockContext }
|
|
154
190
|
>
|
|
155
|
-
{ blockContext ===
|
|
156
|
-
(
|
|
191
|
+
{ blockContext.postId ===
|
|
192
|
+
( activeBlockContextId ||
|
|
193
|
+
blockContexts[ 0 ]?.postId ) ? (
|
|
157
194
|
<PostTemplateInnerBlocks />
|
|
158
|
-
) :
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
195
|
+
) : null }
|
|
196
|
+
<MemoizedPostTemplateBlockPreview
|
|
197
|
+
blocks={ blocks }
|
|
198
|
+
blockContextId={ blockContext.postId }
|
|
199
|
+
setActiveBlockContextId={ setActiveBlockContextId }
|
|
200
|
+
isHidden={
|
|
201
|
+
blockContext.postId ===
|
|
202
|
+
( activeBlockContextId ||
|
|
203
|
+
blockContexts[ 0 ]?.postId )
|
|
204
|
+
}
|
|
205
|
+
/>
|
|
169
206
|
</BlockContextProvider>
|
|
170
207
|
) ) }
|
|
171
208
|
</ul>
|
package/src/site-logo/block.json
CHANGED
|
@@ -6,9 +6,6 @@
|
|
|
6
6
|
"description": "Display a graphic to represent this site. Update the block, and the changes apply everywhere it’s used. This is different than the site icon, which is the smaller image visible in your dashboard, browser tabs, etc used to help others recognize this site.",
|
|
7
7
|
"textdomain": "default",
|
|
8
8
|
"attributes": {
|
|
9
|
-
"align": {
|
|
10
|
-
"type": "string"
|
|
11
|
-
},
|
|
12
9
|
"width": {
|
|
13
10
|
"type": "number"
|
|
14
11
|
},
|
package/src/site-logo/edit.js
CHANGED
|
@@ -142,7 +142,11 @@ const SiteLogo = ( {
|
|
|
142
142
|
return <div style={ { width, height } }>{ imgWrapper }</div>;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
// Set the default width to a responsible size.
|
|
146
|
+
// Note that this width is also set in the attached frontend CSS file.
|
|
147
|
+
const defaultWidth = 120;
|
|
148
|
+
|
|
149
|
+
const currentWidth = width || defaultWidth;
|
|
146
150
|
const ratio = naturalWidth / naturalHeight;
|
|
147
151
|
const currentHeight = currentWidth / ratio;
|
|
148
152
|
const minWidth = naturalWidth < naturalHeight ? MIN_SIZE : MIN_SIZE * ratio;
|
|
@@ -160,10 +164,6 @@ const SiteLogo = ( {
|
|
|
160
164
|
// becomes available.
|
|
161
165
|
const maxWidthBuffer = maxWidth * 2.5;
|
|
162
166
|
|
|
163
|
-
// Set the default width to a responsible size.
|
|
164
|
-
// Note that this width is also set in the attached CSS file.
|
|
165
|
-
const defaultWidth = 120;
|
|
166
|
-
|
|
167
167
|
let showRightHandle = false;
|
|
168
168
|
let showLeftHandle = false;
|
|
169
169
|
|
|
@@ -383,6 +383,7 @@ export default function LogoEdit( {
|
|
|
383
383
|
const onRemoveLogo = () => {
|
|
384
384
|
setLogo( null );
|
|
385
385
|
setLogoUrl( undefined );
|
|
386
|
+
setAttributes( { width: undefined } );
|
|
386
387
|
};
|
|
387
388
|
|
|
388
389
|
const { createErrorNotice } = useDispatch( noticesStore );
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.wp-block[data-align="center"] > .wp-block-site-logo {
|
|
2
|
+
display: table;
|
|
2
3
|
margin-left: auto;
|
|
3
4
|
margin-right: auto;
|
|
4
|
-
text-align: center;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
.wp-block-site-logo {
|
|
@@ -10,20 +10,6 @@
|
|
|
10
10
|
pointer-events: none;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
&:not(.is-default-size) {
|
|
14
|
-
display: table;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Provide a sane starting point for the size.
|
|
18
|
-
&.is-default-size {
|
|
19
|
-
width: 120px;
|
|
20
|
-
|
|
21
|
-
img {
|
|
22
|
-
height: auto;
|
|
23
|
-
width: 100%;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
13
|
.custom-logo-link {
|
|
28
14
|
cursor: inherit;
|
|
29
15
|
|
package/src/site-logo/index.php
CHANGED
|
@@ -48,10 +48,6 @@ function render_block_core_site_logo( $attributes ) {
|
|
|
48
48
|
$classnames[] = $attributes['className'];
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
if ( ! empty( $attributes['align'] ) && in_array( $attributes['align'], array( 'center', 'left', 'right' ), true ) ) {
|
|
52
|
-
$classnames[] = "align{$attributes['align']}";
|
|
53
|
-
}
|
|
54
|
-
|
|
55
51
|
if ( empty( $attributes['width'] ) ) {
|
|
56
52
|
$classnames[] = 'is-default-size';
|
|
57
53
|
}
|
package/src/site-logo/style.scss
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { isEmpty } from 'lodash';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -99,7 +104,7 @@ export default function TemplatePartEdit( {
|
|
|
99
104
|
return {
|
|
100
105
|
innerBlocks: getBlocks( clientId ),
|
|
101
106
|
isResolved: hasResolvedEntity,
|
|
102
|
-
isMissing: hasResolvedEntity &&
|
|
107
|
+
isMissing: hasResolvedEntity && isEmpty( entityRecord ),
|
|
103
108
|
defaultWrapper: defaultWrapperElement || 'div',
|
|
104
109
|
area: _area,
|
|
105
110
|
enableSelection: _enableSelection,
|
|
@@ -64,8 +64,11 @@ function render_block_core_template_part( $attributes ) {
|
|
|
64
64
|
} else {
|
|
65
65
|
// Else, if the template part was provided by the active theme,
|
|
66
66
|
// render the corresponding file content.
|
|
67
|
-
$
|
|
68
|
-
$
|
|
67
|
+
$parent_theme_folders = get_block_theme_folders( get_template() );
|
|
68
|
+
$child_theme_folders = get_block_theme_folders( get_stylesheet() );
|
|
69
|
+
$child_theme_part_file_path = get_theme_file_path( '/' . $child_theme_folders['wp_template_part'] . '/' . $attributes['slug'] . '.html' );
|
|
70
|
+
$parent_theme_part_file_path = get_theme_file_path( '/' . $parent_theme_folders['wp_template_part'] . '/' . $attributes['slug'] . '.html' );
|
|
71
|
+
$template_part_file_path = 0 === validate_file( $attributes['slug'] ) && file_exists( $child_theme_part_file_path ) ? $child_theme_part_file_path : $parent_theme_part_file_path;
|
|
69
72
|
if ( 0 === validate_file( $attributes['slug'] ) && file_exists( $template_part_file_path ) ) {
|
|
70
73
|
$content = file_get_contents( $template_part_file_path );
|
|
71
74
|
$content = is_string( $content ) && '' !== $content
|