@wordpress/block-library 8.33.0 → 8.34.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/block/edit.js +15 -8
- package/build/block/edit.js.map +1 -1
- package/build/block-keyboard-shortcuts/index.js +95 -0
- package/build/block-keyboard-shortcuts/index.js.map +1 -0
- package/build/column/edit.js +28 -19
- package/build/column/edit.js.map +1 -1
- package/build/column/edit.native.js +3 -1
- package/build/column/edit.native.js.map +1 -1
- package/build/columns/edit.js +69 -53
- package/build/columns/edit.js.map +1 -1
- package/build/columns/variations.js +18 -28
- package/build/columns/variations.js.map +1 -1
- package/build/comment-template/util.js +3 -1
- package/build/comment-template/util.js.map +1 -1
- package/build/cover/shared.js +3 -1
- package/build/cover/shared.js.map +1 -1
- package/build/embed/embed-placeholder.js +8 -3
- package/build/embed/embed-placeholder.js.map +1 -1
- package/build/embed/util.js +3 -1
- package/build/embed/util.js.map +1 -1
- package/build/embed/variations.js +3 -1
- package/build/embed/variations.js.map +1 -1
- package/build/embed/wp-embed-preview.js +6 -2
- package/build/embed/wp-embed-preview.js.map +1 -1
- package/build/group/index.js +0 -8
- package/build/group/index.js.map +1 -1
- package/build/group/placeholder.js +18 -19
- package/build/group/placeholder.js.map +1 -1
- package/build/image/image.js +3 -1
- package/build/image/image.js.map +1 -1
- package/build/image/view.js +3 -1
- package/build/image/view.js.map +1 -1
- package/build/index.js +9 -1
- package/build/index.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +12 -4
- package/build/list-item/hooks/use-merge.js.map +1 -1
- package/build/list-item/hooks/use-outdent-list-item.js +15 -5
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/navigation/edit/are-blocks-dirty.js +9 -3
- package/build/navigation/edit/are-blocks-dirty.js.map +1 -1
- package/build/navigation/edit/deleted-navigation-warning.js +1 -1
- package/build/navigation/edit/deleted-navigation-warning.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +3 -1
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +1 -1
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/index.js +0 -9
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/view.js +3 -1
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +94 -85
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/link-ui.js +2 -7
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/paragraph/index.js +0 -1
- package/build/paragraph/index.js.map +1 -1
- package/build/paragraph/transforms.js +0 -1
- package/build/paragraph/transforms.js.map +1 -1
- package/build/post-excerpt/edit.js +3 -1
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +3 -1
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-navigation-link/variations.js +3 -1
- package/build/post-navigation-link/variations.js.map +1 -1
- package/build/post-template/edit.js +18 -8
- package/build/post-template/edit.js.map +1 -1
- package/build/post-terms/edit.js +3 -1
- package/build/post-terms/edit.js.map +1 -1
- package/build/private-apis.js +21 -0
- package/build/private-apis.js.map +1 -0
- package/build/query/edit/enhanced-pagination-modal.js +1 -1
- package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build/query/edit/inspector-controls/author-control.js +6 -2
- package/build/query/edit/inspector-controls/author-control.js.map +1 -1
- package/build/query/edit/inspector-controls/create-new-post-link.js +3 -1
- package/build/query/edit/inspector-controls/create-new-post-link.js.map +1 -1
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js +6 -3
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build/query/edit/inspector-controls/parent-control.js +18 -6
- package/build/query/edit/inspector-controls/parent-control.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +9 -3
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query/utils.js +3 -1
- package/build/query/utils.js.map +1 -1
- package/build/query-title/variations.js +3 -1
- package/build/query-title/variations.js.map +1 -1
- package/build/social-link/edit.js +1 -1
- package/build/social-link/edit.js.map +1 -1
- package/build/social-link/variations.js +3 -1
- package/build/social-link/variations.js.map +1 -1
- package/build/template-part/variations.js +6 -2
- package/build/template-part/variations.js.map +1 -1
- package/build-module/block/edit.js +15 -8
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block-keyboard-shortcuts/index.js +88 -0
- package/build-module/block-keyboard-shortcuts/index.js.map +1 -0
- package/build-module/column/edit.js +28 -19
- package/build-module/column/edit.js.map +1 -1
- package/build-module/column/edit.native.js +3 -1
- package/build-module/column/edit.native.js.map +1 -1
- package/build-module/columns/edit.js +69 -53
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/columns/variations.js +18 -28
- package/build-module/columns/variations.js.map +1 -1
- package/build-module/comment-template/util.js +3 -1
- package/build-module/comment-template/util.js.map +1 -1
- package/build-module/cover/shared.js +3 -1
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/embed/embed-placeholder.js +9 -4
- package/build-module/embed/embed-placeholder.js.map +1 -1
- package/build-module/embed/util.js +3 -1
- package/build-module/embed/util.js.map +1 -1
- package/build-module/embed/variations.js +3 -1
- package/build-module/embed/variations.js.map +1 -1
- package/build-module/embed/wp-embed-preview.js +6 -2
- package/build-module/embed/wp-embed-preview.js.map +1 -1
- package/build-module/group/index.js +0 -8
- package/build-module/group/index.js.map +1 -1
- package/build-module/group/placeholder.js +18 -19
- package/build-module/group/placeholder.js.map +1 -1
- package/build-module/image/image.js +3 -1
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/view.js +3 -1
- package/build-module/image/view.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +12 -4
- package/build-module/list-item/hooks/use-merge.js.map +1 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js +15 -5
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/navigation/edit/are-blocks-dirty.js +9 -3
- package/build-module/navigation/edit/are-blocks-dirty.js.map +1 -1
- package/build-module/navigation/edit/deleted-navigation-warning.js +1 -1
- package/build-module/navigation/edit/deleted-navigation-warning.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +3 -1
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/index.js +0 -9
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/view.js +3 -1
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +94 -85
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +3 -8
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/paragraph/index.js +0 -1
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/paragraph/transforms.js +0 -1
- package/build-module/paragraph/transforms.js.map +1 -1
- package/build-module/post-excerpt/edit.js +3 -1
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +3 -1
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-navigation-link/variations.js +3 -1
- package/build-module/post-navigation-link/variations.js.map +1 -1
- package/build-module/post-template/edit.js +18 -8
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-terms/edit.js +3 -1
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/private-apis.js +14 -0
- package/build-module/private-apis.js.map +1 -0
- package/build-module/query/edit/enhanced-pagination-modal.js +1 -1
- package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build-module/query/edit/inspector-controls/author-control.js +6 -2
- package/build-module/query/edit/inspector-controls/author-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/create-new-post-link.js +3 -1
- package/build-module/query/edit/inspector-controls/create-new-post-link.js.map +1 -1
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +6 -3
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/parent-control.js +18 -6
- package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +9 -3
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query/utils.js +3 -1
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query-title/variations.js +3 -1
- package/build-module/query-title/variations.js.map +1 -1
- package/build-module/social-link/edit.js +1 -1
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-link/variations.js +3 -1
- package/build-module/social-link/variations.js.map +1 -1
- package/build-module/template-part/variations.js +6 -2
- package/build-module/template-part/variations.js.map +1 -1
- package/build-style/editor-rtl.css +15 -49
- package/build-style/editor.css +15 -49
- package/build-style/embed/editor-rtl.css +0 -3
- package/build-style/embed/editor.css +0 -3
- package/build-style/group/editor-rtl.css +0 -44
- package/build-style/group/editor.css +0 -44
- package/build-style/group/style-rtl.css +4 -0
- package/build-style/group/style.css +4 -0
- package/build-style/navigation-link/style-rtl.css +0 -8
- package/build-style/navigation-link/style.css +0 -8
- package/build-style/post-featured-image/editor-rtl.css +1 -0
- package/build-style/post-featured-image/editor.css +1 -0
- package/build-style/site-logo/editor-rtl.css +1 -0
- package/build-style/site-logo/editor.css +1 -0
- package/build-style/social-link/editor-rtl.css +13 -2
- package/build-style/social-link/editor.css +13 -2
- package/build-style/style-rtl.css +4 -8
- package/build-style/style.css +4 -8
- package/package.json +35 -34
- package/src/block/edit.js +19 -12
- package/src/block-keyboard-shortcuts/index.js +113 -0
- package/src/column/edit.js +26 -20
- package/src/column/edit.native.js +3 -1
- package/src/columns/edit.js +93 -83
- package/src/columns/variations.js +12 -34
- package/src/comment-template/util.js +3 -1
- package/src/cover/shared.js +3 -1
- package/src/embed/editor.scss +0 -2
- package/src/embed/embed-placeholder.js +21 -9
- package/src/embed/util.js +3 -1
- package/src/embed/variations.js +3 -1
- package/src/embed/wp-embed-preview.js +6 -2
- package/src/gallery/test/helpers.native.js +3 -3
- package/src/group/editor.scss +0 -47
- package/src/group/index.js +0 -8
- package/src/group/placeholder.js +18 -18
- package/src/group/style.scss +5 -0
- package/src/image/image.js +3 -1
- package/src/image/view.js +3 -1
- package/src/index.js +2 -0
- package/src/list-item/hooks/use-merge.js +12 -4
- package/src/list-item/hooks/use-outdent-list-item.js +15 -5
- package/src/navigation/block.json +0 -9
- package/src/navigation/edit/are-blocks-dirty.js +8 -3
- package/src/navigation/edit/deleted-navigation-warning.js +1 -1
- package/src/navigation/edit/menu-inspector-controls.js +3 -1
- package/src/navigation/edit/navigation-menu-selector.js +1 -1
- package/src/navigation/edit/test/navigation-menu-selector.js +5 -5
- package/src/navigation/view.js +3 -1
- package/src/navigation-link/edit.js +91 -91
- package/src/navigation-link/link-ui.js +74 -89
- package/src/navigation-link/style.scss +0 -12
- package/src/paragraph/block.json +0 -1
- package/src/post-excerpt/edit.js +3 -1
- package/src/post-featured-image/dimension-controls.js +3 -1
- package/src/post-featured-image/editor.scss +1 -0
- package/src/post-navigation-link/variations.js +3 -1
- package/src/post-template/edit.js +9 -4
- package/src/post-terms/edit.js +3 -1
- package/src/private-apis.js +13 -0
- package/src/query/edit/enhanced-pagination-modal.js +5 -1
- package/src/query/edit/inspector-controls/author-control.js +6 -2
- package/src/query/edit/inspector-controls/create-new-post-link.js +3 -1
- package/src/query/edit/inspector-controls/enhanced-pagination-control.js +13 -3
- package/src/query/edit/inspector-controls/parent-control.js +18 -6
- package/src/query/edit/inspector-controls/taxonomy-controls.js +9 -3
- package/src/query/index.php +1 -1
- package/src/query/utils.js +3 -1
- package/src/query-title/variations.js +3 -1
- package/src/site-logo/editor.scss +1 -0
- package/src/social-link/edit.js +2 -2
- package/src/social-link/editor.scss +25 -11
- package/src/social-link/variations.js +3 -1
- package/src/template-part/variations.js +6 -2
package/src/embed/variations.js
CHANGED
|
@@ -368,7 +368,9 @@ const variations = [
|
|
|
368
368
|
* Block by providing its attributes.
|
|
369
369
|
*/
|
|
370
370
|
variations.forEach( ( variation ) => {
|
|
371
|
-
if ( variation.isActive )
|
|
371
|
+
if ( variation.isActive ) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
372
374
|
variation.isActive = ( blockAttributes, variationAttributes ) =>
|
|
373
375
|
blockAttributes.providerNameSlug ===
|
|
374
376
|
variationAttributes.providerNameSlug;
|
|
@@ -20,10 +20,14 @@ export default function WpEmbedPreview( { html } ) {
|
|
|
20
20
|
const iframe = doc.querySelector( 'iframe' );
|
|
21
21
|
const iframeProps = {};
|
|
22
22
|
|
|
23
|
-
if ( ! iframe )
|
|
23
|
+
if ( ! iframe ) {
|
|
24
|
+
return iframeProps;
|
|
25
|
+
}
|
|
24
26
|
|
|
25
27
|
Array.from( iframe.attributes ).forEach( ( { name, value } ) => {
|
|
26
|
-
if ( name === 'style' )
|
|
28
|
+
if ( name === 'style' ) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
27
31
|
iframeProps[ attributeMap[ name ] || name ] = value;
|
|
28
32
|
} );
|
|
29
33
|
|
|
@@ -65,9 +65,9 @@ export const initializeWithGalleryBlock = async ( {
|
|
|
65
65
|
/**
|
|
66
66
|
* Gets a gallery item within a Gallery block.
|
|
67
67
|
*
|
|
68
|
-
* @param {
|
|
69
|
-
* @param {number}
|
|
70
|
-
* @return {
|
|
68
|
+
* @param {HTMLElement} galleryBlock Gallery block instance.
|
|
69
|
+
* @param {number} rowIndex Row position within the Gallery block.
|
|
70
|
+
* @return {HTMLElement} Gallery item.
|
|
71
71
|
*/
|
|
72
72
|
export const getGalleryItem = ( galleryBlock, rowIndex ) =>
|
|
73
73
|
getInnerBlock( galleryBlock, 'Image', { rowIndex } );
|
package/src/group/editor.scss
CHANGED
|
@@ -53,50 +53,3 @@
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
.wp-block-group__placeholder {
|
|
57
|
-
.wp-block-group-placeholder__variations {
|
|
58
|
-
list-style: none;
|
|
59
|
-
display: flex;
|
|
60
|
-
justify-content: center;
|
|
61
|
-
flex-direction: row;
|
|
62
|
-
flex-wrap: wrap;
|
|
63
|
-
width: 100%;
|
|
64
|
-
padding: 0;
|
|
65
|
-
margin: 0;
|
|
66
|
-
}
|
|
67
|
-
.components-placeholder__instructions {
|
|
68
|
-
margin-bottom: 18px;
|
|
69
|
-
}
|
|
70
|
-
.wp-block-group-placeholder__variations svg {
|
|
71
|
-
fill: $gray-400 !important;
|
|
72
|
-
}
|
|
73
|
-
.wp-block-group-placeholder__variations svg:hover {
|
|
74
|
-
fill: var(--wp-admin-theme-color) !important;
|
|
75
|
-
}
|
|
76
|
-
.wp-block-group-placeholder__variations > li {
|
|
77
|
-
margin: 0 $grid-unit-15 $grid-unit-15 $grid-unit-15;
|
|
78
|
-
width: auto;
|
|
79
|
-
display: flex;
|
|
80
|
-
flex-direction: column;
|
|
81
|
-
align-items: center;
|
|
82
|
-
}
|
|
83
|
-
.wp-block-group-placeholder__variations li > .wp-block-group-placeholder__variation-button {
|
|
84
|
-
width: 44px;
|
|
85
|
-
height: 32px;
|
|
86
|
-
padding: 0;
|
|
87
|
-
&:hover {
|
|
88
|
-
box-shadow: none;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
.components-placeholder {
|
|
92
|
-
min-height: auto;
|
|
93
|
-
padding: $grid-unit-30;
|
|
94
|
-
align-items: center;
|
|
95
|
-
}
|
|
96
|
-
.is-small,
|
|
97
|
-
.is-medium {
|
|
98
|
-
.wp-block-group-placeholder__variations > li {
|
|
99
|
-
margin: $grid-unit-15;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
package/src/group/index.js
CHANGED
package/src/group/placeholder.js
CHANGED
|
@@ -20,42 +20,41 @@ const getGroupPlaceholderIcons = ( name = 'group' ) => {
|
|
|
20
20
|
group: (
|
|
21
21
|
<SVG
|
|
22
22
|
xmlns="http://www.w3.org/2000/svg"
|
|
23
|
-
width="
|
|
24
|
-
height="
|
|
25
|
-
viewBox="0 0
|
|
23
|
+
width="48"
|
|
24
|
+
height="48"
|
|
25
|
+
viewBox="0 0 48 48"
|
|
26
26
|
>
|
|
27
|
-
<Path d="
|
|
27
|
+
<Path d="M0 10a2 2 0 0 1 2-2h44a2 2 0 0 1 2 2v28a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V10Z" />
|
|
28
28
|
</SVG>
|
|
29
29
|
),
|
|
30
30
|
'group-row': (
|
|
31
31
|
<SVG
|
|
32
32
|
xmlns="http://www.w3.org/2000/svg"
|
|
33
|
-
width="
|
|
34
|
-
height="
|
|
35
|
-
viewBox="0 0
|
|
33
|
+
width="48"
|
|
34
|
+
height="48"
|
|
35
|
+
viewBox="0 0 48 48"
|
|
36
36
|
>
|
|
37
|
-
<Path d="
|
|
37
|
+
<Path d="M0 10a2 2 0 0 1 2-2h19a2 2 0 0 1 2 2v28a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V10Zm25 0a2 2 0 0 1 2-2h19a2 2 0 0 1 2 2v28a2 2 0 0 1-2 2H27a2 2 0 0 1-2-2V10Z" />
|
|
38
38
|
</SVG>
|
|
39
39
|
),
|
|
40
40
|
'group-stack': (
|
|
41
41
|
<SVG
|
|
42
42
|
xmlns="http://www.w3.org/2000/svg"
|
|
43
|
-
width="
|
|
44
|
-
height="
|
|
45
|
-
viewBox="0 0
|
|
43
|
+
width="48"
|
|
44
|
+
height="48"
|
|
45
|
+
viewBox="0 0 48 48"
|
|
46
46
|
>
|
|
47
|
-
<Path d="
|
|
47
|
+
<Path d="M0 10a2 2 0 0 1 2-2h44a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V10Zm0 17a2 2 0 0 1 2-2h44a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V27Z" />
|
|
48
48
|
</SVG>
|
|
49
49
|
),
|
|
50
50
|
'group-grid': (
|
|
51
51
|
<SVG
|
|
52
52
|
xmlns="http://www.w3.org/2000/svg"
|
|
53
|
-
width="
|
|
54
|
-
height="
|
|
55
|
-
viewBox="0 0
|
|
53
|
+
width="48"
|
|
54
|
+
height="48"
|
|
55
|
+
viewBox="0 0 48 48"
|
|
56
56
|
>
|
|
57
|
-
<Path d="
|
|
58
|
-
<Path d="m42.73056,-0.03617l-18.59217,0c-0.84788,0.07234 -1.38868,0.79149 -1.38868,1.89149l0,12.64468c0,0.6 0.71928,0.96383 1.00973,0.96383l19.27997,0.03617c0.29045,0 1.00973,-0.4 1.00973,-1l-0.03504,-12.7532c0,-1.1 -0.75106,-1.78297 -1.28355,-1.78297zm0.51912,16.60851l-19.59537,-0.03617c-0.29045,0 -0.9046,0.36383 -0.9046,0.96383l-0.03504,12.68085c0,1.1 0.78611,1.81915 1.31859,1.81915l18.62721,0c0.53249,0 1.42372,-0.71915 1.42372,-1.81915l0,-12.53617c0,-0.6 -0.54407,-1.07234 -0.83451,-1.07234z" />
|
|
57
|
+
<Path d="M0 10a2 2 0 0 1 2-2h19a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V10Zm25 0a2 2 0 0 1 2-2h19a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H27a2 2 0 0 1-2-2V10ZM0 27a2 2 0 0 1 2-2h19a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V27Zm25 0a2 2 0 0 1 2-2h19a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H27a2 2 0 0 1-2-2V27Z" />
|
|
59
58
|
</SVG>
|
|
60
59
|
),
|
|
61
60
|
};
|
|
@@ -159,11 +158,12 @@ function GroupPlaceHolder( { name, onSelect } ) {
|
|
|
159
158
|
{ variations.map( ( variation ) => (
|
|
160
159
|
<li key={ variation.name }>
|
|
161
160
|
<Button
|
|
161
|
+
__next40pxDefaultSize
|
|
162
162
|
variant="tertiary"
|
|
163
163
|
icon={ getGroupPlaceholderIcons(
|
|
164
164
|
variation.name
|
|
165
165
|
) }
|
|
166
|
-
iconSize={
|
|
166
|
+
iconSize={ 48 }
|
|
167
167
|
onClick={ () => onSelect( variation ) }
|
|
168
168
|
className="wp-block-group-placeholder__variation-button"
|
|
169
169
|
label={ `${ variation.title }: ${ variation.description }` }
|
package/src/group/style.scss
CHANGED
|
@@ -2,3 +2,8 @@
|
|
|
2
2
|
// This block has customizable padding, border-box makes that more predictable.
|
|
3
3
|
box-sizing: border-box;
|
|
4
4
|
}
|
|
5
|
+
|
|
6
|
+
// We need this so groups with negative margins overlap as expected.
|
|
7
|
+
:where(.wp-block-group.wp-block-group-is-layout-constrained) {
|
|
8
|
+
position: relative;
|
|
9
|
+
}
|
package/src/image/image.js
CHANGED
package/src/image/view.js
CHANGED
package/src/index.js
CHANGED
|
@@ -35,8 +35,12 @@ export default function useMerge( clientId, onMerge ) {
|
|
|
35
35
|
function getParentListItemId( id ) {
|
|
36
36
|
const listId = getBlockRootClientId( id );
|
|
37
37
|
const parentListItemId = getBlockRootClientId( listId );
|
|
38
|
-
if ( ! parentListItemId )
|
|
39
|
-
|
|
38
|
+
if ( ! parentListItemId ) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if ( getBlockName( parentListItemId ) !== 'core/list-item' ) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
40
44
|
return parentListItemId;
|
|
41
45
|
}
|
|
42
46
|
|
|
@@ -49,9 +53,13 @@ export default function useMerge( clientId, onMerge ) {
|
|
|
49
53
|
*/
|
|
50
54
|
function _getNextId( id ) {
|
|
51
55
|
const next = getNextBlockClientId( id );
|
|
52
|
-
if ( next )
|
|
56
|
+
if ( next ) {
|
|
57
|
+
return next;
|
|
58
|
+
}
|
|
53
59
|
const parentListItemId = getParentListItemId( id );
|
|
54
|
-
if ( ! parentListItemId )
|
|
60
|
+
if ( ! parentListItemId ) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
55
63
|
return _getNextId( parentListItemId );
|
|
56
64
|
}
|
|
57
65
|
|
|
@@ -27,8 +27,12 @@ export default function useOutdentListItem() {
|
|
|
27
27
|
function getParentListItemId( id ) {
|
|
28
28
|
const listId = getBlockRootClientId( id );
|
|
29
29
|
const parentListItemId = getBlockRootClientId( listId );
|
|
30
|
-
if ( ! parentListItemId )
|
|
31
|
-
|
|
30
|
+
if ( ! parentListItemId ) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if ( getBlockName( parentListItemId ) !== 'core/list-item' ) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
32
36
|
return parentListItemId;
|
|
33
37
|
}
|
|
34
38
|
|
|
@@ -37,17 +41,23 @@ export default function useOutdentListItem() {
|
|
|
37
41
|
clientIds = [ clientIds ];
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
if ( ! clientIds.length )
|
|
44
|
+
if ( ! clientIds.length ) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
41
47
|
|
|
42
48
|
const firstClientId = clientIds[ 0 ];
|
|
43
49
|
|
|
44
50
|
// Can't outdent if it's not a list item.
|
|
45
|
-
if ( getBlockName( firstClientId ) !== 'core/list-item' )
|
|
51
|
+
if ( getBlockName( firstClientId ) !== 'core/list-item' ) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
46
54
|
|
|
47
55
|
const parentListItemId = getParentListItemId( firstClientId );
|
|
48
56
|
|
|
49
57
|
// Can't outdent if it's at the top level.
|
|
50
|
-
if ( ! parentListItemId )
|
|
58
|
+
if ( ! parentListItemId ) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
51
61
|
|
|
52
62
|
const parentListId = getBlockRootClientId( firstClientId );
|
|
53
63
|
const lastClientId = clientIds[ clientIds.length - 1 ];
|
|
@@ -30,7 +30,9 @@ const isDeepEqual = ( x, y, shouldSkip ) => {
|
|
|
30
30
|
y !== null &&
|
|
31
31
|
y !== undefined
|
|
32
32
|
) {
|
|
33
|
-
if ( Object.keys( x ).length !== Object.keys( y ).length )
|
|
33
|
+
if ( Object.keys( x ).length !== Object.keys( y ).length ) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
34
36
|
|
|
35
37
|
for ( const prop in x ) {
|
|
36
38
|
if ( y.hasOwnProperty( prop ) ) {
|
|
@@ -39,9 +41,12 @@ const isDeepEqual = ( x, y, shouldSkip ) => {
|
|
|
39
41
|
return true;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
if ( ! isDeepEqual( x[ prop ], y[ prop ], shouldSkip ) )
|
|
44
|
+
if ( ! isDeepEqual( x[ prop ], y[ prop ], shouldSkip ) ) {
|
|
43
45
|
return false;
|
|
44
|
-
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
return true;
|
|
@@ -11,7 +11,7 @@ function DeletedNavigationWarning( { onCreateNew } ) {
|
|
|
11
11
|
<Warning>
|
|
12
12
|
{ createInterpolateElement(
|
|
13
13
|
__(
|
|
14
|
-
'Navigation Menu has been deleted or is unavailable. <button>Create a new
|
|
14
|
+
'Navigation Menu has been deleted or is unavailable. <button>Create a new Menu?</button>'
|
|
15
15
|
),
|
|
16
16
|
{
|
|
17
17
|
button: <Button onClick={ onCreateNew } variant="link" />,
|
|
@@ -49,7 +49,9 @@ function AdditionalBlockContent( { block, insertedBlock, setInsertedBlock } ) {
|
|
|
49
49
|
|
|
50
50
|
const setInsertedBlockAttributes =
|
|
51
51
|
( _insertedBlockClientId ) => ( _updatedAttributes ) => {
|
|
52
|
-
if ( ! _insertedBlockClientId )
|
|
52
|
+
if ( ! _insertedBlockClientId ) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
53
55
|
updateBlockAttributes( _insertedBlockClientId, _updatedAttributes );
|
|
54
56
|
};
|
|
55
57
|
|
|
@@ -191,7 +191,7 @@ describe( 'NavigationMenuSelector', () => {
|
|
|
191
191
|
expect( toolsGroup ).toBeInTheDocument();
|
|
192
192
|
|
|
193
193
|
const createMenuButton = screen.getByRole( 'menuitem', {
|
|
194
|
-
name: 'Create new
|
|
194
|
+
name: 'Create new Menu',
|
|
195
195
|
} );
|
|
196
196
|
|
|
197
197
|
expect( createMenuButton ).toBeInTheDocument();
|
|
@@ -236,7 +236,7 @@ describe( 'NavigationMenuSelector', () => {
|
|
|
236
236
|
await user.click( toggleButton );
|
|
237
237
|
|
|
238
238
|
const createMenuButton = screen.getByRole( 'menuitem', {
|
|
239
|
-
name: 'Create new
|
|
239
|
+
name: 'Create new Menu',
|
|
240
240
|
} );
|
|
241
241
|
|
|
242
242
|
await user.click( createMenuButton );
|
|
@@ -268,7 +268,7 @@ describe( 'NavigationMenuSelector', () => {
|
|
|
268
268
|
|
|
269
269
|
await user.click(
|
|
270
270
|
screen.getByRole( 'menuitem', {
|
|
271
|
-
name: 'Create new
|
|
271
|
+
name: 'Create new Menu',
|
|
272
272
|
} )
|
|
273
273
|
);
|
|
274
274
|
|
|
@@ -293,7 +293,7 @@ describe( 'NavigationMenuSelector', () => {
|
|
|
293
293
|
// Check the "Create menu" button is disabled.
|
|
294
294
|
expect(
|
|
295
295
|
screen.queryByRole( 'menuitem', {
|
|
296
|
-
name: 'Create new
|
|
296
|
+
name: 'Create new Menu',
|
|
297
297
|
} )
|
|
298
298
|
).toBeDisabled();
|
|
299
299
|
|
|
@@ -318,7 +318,7 @@ describe( 'NavigationMenuSelector', () => {
|
|
|
318
318
|
// Check the button is enabled again.
|
|
319
319
|
expect(
|
|
320
320
|
screen.queryByRole( 'menuitem', {
|
|
321
|
-
name: 'Create new
|
|
321
|
+
name: 'Create new Menu',
|
|
322
322
|
} )
|
|
323
323
|
).toBeEnabled();
|
|
324
324
|
} );
|
package/src/navigation/view.js
CHANGED
|
@@ -94,7 +94,9 @@ const { state, actions } = store(
|
|
|
94
94
|
const ctx = getContext();
|
|
95
95
|
const { ref } = getElement();
|
|
96
96
|
// Safari won't send focus to the clicked element, so we need to manually place it: https://bugs.webkit.org/show_bug.cgi?id=22261
|
|
97
|
-
if ( window.document.activeElement !== ref )
|
|
97
|
+
if ( window.document.activeElement !== ref ) {
|
|
98
|
+
ref.focus();
|
|
99
|
+
}
|
|
98
100
|
const { menuOpenedBy } = state;
|
|
99
101
|
if ( menuOpenedBy.click || menuOpenedBy.focus ) {
|
|
100
102
|
actions.closeMenu( 'click' );
|
|
@@ -153,6 +153,82 @@ function getMissingText( type ) {
|
|
|
153
153
|
return missingText;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
/*
|
|
157
|
+
* Warning, this duplicated in
|
|
158
|
+
* packages/block-library/src/navigation-submenu/edit.js
|
|
159
|
+
* Consider reuseing this components for both blocks.
|
|
160
|
+
*/
|
|
161
|
+
function Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) {
|
|
162
|
+
const { label, url, description, title, rel } = attributes;
|
|
163
|
+
return (
|
|
164
|
+
<PanelBody title={ __( 'Settings' ) }>
|
|
165
|
+
<TextControl
|
|
166
|
+
__nextHasNoMarginBottom
|
|
167
|
+
__next40pxDefaultSize
|
|
168
|
+
value={ label ? stripHTML( label ) : '' }
|
|
169
|
+
onChange={ ( labelValue ) => {
|
|
170
|
+
setAttributes( { label: labelValue } );
|
|
171
|
+
} }
|
|
172
|
+
label={ __( 'Text' ) }
|
|
173
|
+
autoComplete="off"
|
|
174
|
+
onFocus={ () => setIsLabelFieldFocused( true ) }
|
|
175
|
+
onBlur={ () => setIsLabelFieldFocused( false ) }
|
|
176
|
+
/>
|
|
177
|
+
<TextControl
|
|
178
|
+
__nextHasNoMarginBottom
|
|
179
|
+
__next40pxDefaultSize
|
|
180
|
+
value={ url ? safeDecodeURI( url ) : '' }
|
|
181
|
+
onChange={ ( urlValue ) => {
|
|
182
|
+
updateAttributes(
|
|
183
|
+
{ url: urlValue },
|
|
184
|
+
setAttributes,
|
|
185
|
+
attributes
|
|
186
|
+
);
|
|
187
|
+
} }
|
|
188
|
+
label={ __( 'Link' ) }
|
|
189
|
+
autoComplete="off"
|
|
190
|
+
/>
|
|
191
|
+
<TextareaControl
|
|
192
|
+
__nextHasNoMarginBottom
|
|
193
|
+
value={ description || '' }
|
|
194
|
+
onChange={ ( descriptionValue ) => {
|
|
195
|
+
setAttributes( { description: descriptionValue } );
|
|
196
|
+
} }
|
|
197
|
+
label={ __( 'Description' ) }
|
|
198
|
+
help={ __(
|
|
199
|
+
'The description will be displayed in the menu if the current theme supports it.'
|
|
200
|
+
) }
|
|
201
|
+
/>
|
|
202
|
+
<TextControl
|
|
203
|
+
__nextHasNoMarginBottom
|
|
204
|
+
__next40pxDefaultSize
|
|
205
|
+
value={ title || '' }
|
|
206
|
+
onChange={ ( titleValue ) => {
|
|
207
|
+
setAttributes( { title: titleValue } );
|
|
208
|
+
} }
|
|
209
|
+
label={ __( 'Title attribute' ) }
|
|
210
|
+
autoComplete="off"
|
|
211
|
+
help={ __(
|
|
212
|
+
'Additional information to help clarify the purpose of the link.'
|
|
213
|
+
) }
|
|
214
|
+
/>
|
|
215
|
+
<TextControl
|
|
216
|
+
__nextHasNoMarginBottom
|
|
217
|
+
__next40pxDefaultSize
|
|
218
|
+
value={ rel || '' }
|
|
219
|
+
onChange={ ( relValue ) => {
|
|
220
|
+
setAttributes( { rel: relValue } );
|
|
221
|
+
} }
|
|
222
|
+
label={ __( 'Rel attribute' ) }
|
|
223
|
+
autoComplete="off"
|
|
224
|
+
help={ __(
|
|
225
|
+
'The relationship of the linked URL as space-separated link types.'
|
|
226
|
+
) }
|
|
227
|
+
/>
|
|
228
|
+
</PanelBody>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
156
232
|
export default function NavigationLinkEdit( {
|
|
157
233
|
attributes,
|
|
158
234
|
isSelected,
|
|
@@ -163,7 +239,7 @@ export default function NavigationLinkEdit( {
|
|
|
163
239
|
context,
|
|
164
240
|
clientId,
|
|
165
241
|
} ) {
|
|
166
|
-
const { id, label, type, url, description,
|
|
242
|
+
const { id, label, type, url, description, kind } = attributes;
|
|
167
243
|
|
|
168
244
|
const [ isInvalid, isDraft ] = useIsInvalidLink( kind, type, id );
|
|
169
245
|
const { maxNestingLevel } = context;
|
|
@@ -171,9 +247,11 @@ export default function NavigationLinkEdit( {
|
|
|
171
247
|
const {
|
|
172
248
|
replaceBlock,
|
|
173
249
|
__unstableMarkNextChangeAsNotPersistent,
|
|
250
|
+
selectBlock,
|
|
174
251
|
selectPreviousBlock,
|
|
175
252
|
} = useDispatch( blockEditorStore );
|
|
176
|
-
|
|
253
|
+
// Have the link editing ui open on mount when lacking a url and selected.
|
|
254
|
+
const [ isLinkOpen, setIsLinkOpen ] = useState( isSelected && ! url );
|
|
177
255
|
// Store what element opened the popover, so we know where to return focus to (toolbar button vs navigation link text)
|
|
178
256
|
const [ openedBy, setOpenedBy ] = useState( null );
|
|
179
257
|
// Use internal state instead of a ref to make sure that the component
|
|
@@ -228,27 +306,19 @@ export default function NavigationLinkEdit( {
|
|
|
228
306
|
* Transform to submenu block.
|
|
229
307
|
*/
|
|
230
308
|
const transformToSubmenu = () => {
|
|
231
|
-
|
|
309
|
+
let innerBlocks = getBlocks( clientId );
|
|
310
|
+
if ( innerBlocks.length === 0 ) {
|
|
311
|
+
innerBlocks = [ createBlock( 'core/navigation-link' ) ];
|
|
312
|
+
selectBlock( innerBlocks[ 0 ].clientId );
|
|
313
|
+
}
|
|
232
314
|
const newSubmenu = createBlock(
|
|
233
315
|
'core/navigation-submenu',
|
|
234
316
|
attributes,
|
|
235
|
-
innerBlocks
|
|
236
|
-
? innerBlocks
|
|
237
|
-
: [ createBlock( 'core/navigation-link' ) ]
|
|
317
|
+
innerBlocks
|
|
238
318
|
);
|
|
239
319
|
replaceBlock( clientId, newSubmenu );
|
|
240
320
|
};
|
|
241
321
|
|
|
242
|
-
useEffect( () => {
|
|
243
|
-
// Show the LinkControl on mount if the URL is empty
|
|
244
|
-
// ( When adding a new menu item)
|
|
245
|
-
// This can't be done in the useState call because it conflicts
|
|
246
|
-
// with the autofocus behavior of the BlockListBlock component.
|
|
247
|
-
if ( ! url ) {
|
|
248
|
-
setIsLinkOpen( true );
|
|
249
|
-
}
|
|
250
|
-
}, [ url ] );
|
|
251
|
-
|
|
252
322
|
useEffect( () => {
|
|
253
323
|
// If block has inner blocks, transform to Submenu.
|
|
254
324
|
if ( hasChildren ) {
|
|
@@ -259,16 +329,6 @@ export default function NavigationLinkEdit( {
|
|
|
259
329
|
}
|
|
260
330
|
}, [ hasChildren ] );
|
|
261
331
|
|
|
262
|
-
/**
|
|
263
|
-
* The hook shouldn't be necessary but due to a focus loss happening
|
|
264
|
-
* when selecting a suggestion in the link popover, we force close on block unselection.
|
|
265
|
-
*/
|
|
266
|
-
useEffect( () => {
|
|
267
|
-
if ( ! isSelected ) {
|
|
268
|
-
setIsLinkOpen( false );
|
|
269
|
-
}
|
|
270
|
-
}, [ isSelected ] );
|
|
271
|
-
|
|
272
332
|
// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.
|
|
273
333
|
useEffect( () => {
|
|
274
334
|
// We only want to do this when the URL has gone from nothing to a new URL AND the label looks like a URL
|
|
@@ -420,71 +480,11 @@ export default function NavigationLinkEdit( {
|
|
|
420
480
|
</BlockControls>
|
|
421
481
|
{ /* Warning, this duplicated in packages/block-library/src/navigation-submenu/edit.js */ }
|
|
422
482
|
<InspectorControls>
|
|
423
|
-
<
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
onChange={ ( labelValue ) => {
|
|
429
|
-
setAttributes( { label: labelValue } );
|
|
430
|
-
} }
|
|
431
|
-
label={ __( 'Text' ) }
|
|
432
|
-
autoComplete="off"
|
|
433
|
-
onFocus={ () => setIsLabelFieldFocused( true ) }
|
|
434
|
-
onBlur={ () => setIsLabelFieldFocused( false ) }
|
|
435
|
-
/>
|
|
436
|
-
<TextControl
|
|
437
|
-
__nextHasNoMarginBottom
|
|
438
|
-
__next40pxDefaultSize
|
|
439
|
-
value={ url ? safeDecodeURI( url ) : '' }
|
|
440
|
-
onChange={ ( urlValue ) => {
|
|
441
|
-
updateAttributes(
|
|
442
|
-
{ url: urlValue },
|
|
443
|
-
setAttributes,
|
|
444
|
-
attributes
|
|
445
|
-
);
|
|
446
|
-
} }
|
|
447
|
-
label={ __( 'Link' ) }
|
|
448
|
-
autoComplete="off"
|
|
449
|
-
/>
|
|
450
|
-
<TextareaControl
|
|
451
|
-
__nextHasNoMarginBottom
|
|
452
|
-
value={ description || '' }
|
|
453
|
-
onChange={ ( descriptionValue ) => {
|
|
454
|
-
setAttributes( { description: descriptionValue } );
|
|
455
|
-
} }
|
|
456
|
-
label={ __( 'Description' ) }
|
|
457
|
-
help={ __(
|
|
458
|
-
'The description will be displayed in the menu if the current theme supports it.'
|
|
459
|
-
) }
|
|
460
|
-
/>
|
|
461
|
-
<TextControl
|
|
462
|
-
__nextHasNoMarginBottom
|
|
463
|
-
__next40pxDefaultSize
|
|
464
|
-
value={ title || '' }
|
|
465
|
-
onChange={ ( titleValue ) => {
|
|
466
|
-
setAttributes( { title: titleValue } );
|
|
467
|
-
} }
|
|
468
|
-
label={ __( 'Title attribute' ) }
|
|
469
|
-
autoComplete="off"
|
|
470
|
-
help={ __(
|
|
471
|
-
'Additional information to help clarify the purpose of the link.'
|
|
472
|
-
) }
|
|
473
|
-
/>
|
|
474
|
-
<TextControl
|
|
475
|
-
__nextHasNoMarginBottom
|
|
476
|
-
__next40pxDefaultSize
|
|
477
|
-
value={ rel || '' }
|
|
478
|
-
onChange={ ( relValue ) => {
|
|
479
|
-
setAttributes( { rel: relValue } );
|
|
480
|
-
} }
|
|
481
|
-
label={ __( 'Rel attribute' ) }
|
|
482
|
-
autoComplete="off"
|
|
483
|
-
help={ __(
|
|
484
|
-
'The relationship of the linked URL as space-separated link types.'
|
|
485
|
-
) }
|
|
486
|
-
/>
|
|
487
|
-
</PanelBody>
|
|
483
|
+
<Controls
|
|
484
|
+
attributes={ attributes }
|
|
485
|
+
setAttributes={ setAttributes }
|
|
486
|
+
setIsLabelFieldFocused={ setIsLabelFieldFocused }
|
|
487
|
+
/>
|
|
488
488
|
</InspectorControls>
|
|
489
489
|
<div { ...blockProps }>
|
|
490
490
|
{ /* eslint-disable jsx-a11y/anchor-is-valid */ }
|