@wordpress/block-library 7.11.0 → 7.12.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/edit.js +7 -0
- package/build/archives/edit.js.map +1 -1
- package/build/archives/index.js +4 -0
- package/build/archives/index.js.map +1 -1
- package/build/block/edit.js +4 -2
- package/build/block/edit.js.map +1 -1
- package/build/block/edit.native.js +4 -2
- package/build/block/edit.native.js.map +1 -1
- package/build/calendar/edit.js +12 -5
- package/build/calendar/edit.js.map +1 -1
- package/build/columns/edit.native.js +2 -1
- package/build/columns/edit.native.js.map +1 -1
- package/build/cover/edit/resizable-cover.js +6 -0
- package/build/cover/edit/resizable-cover.js.map +1 -1
- package/build/group/transforms.js +5 -0
- package/build/group/transforms.js.map +1 -1
- package/build/index.native.js +17 -4
- package/build/index.native.js.map +1 -1
- package/build/list/index.js +6 -0
- package/build/list/index.js.map +1 -1
- package/build/list/v2/edit.js +16 -5
- package/build/list/v2/edit.js.map +1 -1
- package/build/list/v2/tag-name.js +31 -0
- package/build/list/v2/tag-name.js.map +1 -0
- package/build/list/v2/tag-name.native.js +32 -0
- package/build/list/v2/tag-name.native.js.map +1 -0
- package/build/list/v2/transforms.js +1 -11
- package/build/list/v2/transforms.js.map +1 -1
- package/build/list-item/edit.js +1 -0
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/edit.native.js +158 -0
- package/build/list-item/edit.native.js.map +1 -0
- package/build/list-item/icons.native.js +53 -0
- package/build/list-item/icons.native.js.map +1 -0
- package/build/list-item/list-style-type.native.js +136 -0
- package/build/list-item/list-style-type.native.js.map +1 -0
- package/build/media-text/deprecated.js +188 -66
- package/build/media-text/deprecated.js.map +1 -1
- package/build/media-text/edit.js +2 -1
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/media-container.js +1 -1
- package/build/media-text/media-container.js.map +1 -1
- package/build/navigation/edit/index.js +68 -123
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +11 -14
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +4 -2
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +13 -3
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js +5 -1
- package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build/navigation/edit/use-inner-blocks.js +43 -0
- package/build/navigation/edit/use-inner-blocks.js.map +1 -0
- package/build/navigation/edit/utils.js +28 -0
- package/build/navigation/edit/utils.js.map +1 -0
- package/build/navigation/use-navigation-menu.js +7 -3
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/post-author/edit.js +5 -2
- package/build/post-author/edit.js.map +1 -1
- package/build/post-author-biography/edit.js +7 -1
- package/build/post-author-biography/edit.js.map +1 -1
- package/build/post-content/edit.js +4 -2
- package/build/post-content/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +16 -2
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-featured-image/index.js +9 -0
- package/build/post-featured-image/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +42 -9
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +21 -14
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query-title/edit.js +20 -7
- package/build/query-title/edit.js.map +1 -1
- package/build/query-title/index.js +4 -0
- package/build/query-title/index.js.map +1 -1
- package/build/query-title/variations.js +10 -0
- package/build/query-title/variations.js.map +1 -1
- package/build/quote/transforms.js +2 -2
- package/build/quote/transforms.js.map +1 -1
- package/build/separator/edit.js +1 -1
- package/build/separator/edit.js.map +1 -1
- package/build/social-links/edit.js +1 -0
- package/build/social-links/edit.js.map +1 -1
- package/build/template-part/edit/index.js +4 -2
- package/build/template-part/edit/index.js.map +1 -1
- package/build-module/archives/edit.js +7 -0
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/archives/index.js +4 -0
- package/build-module/archives/index.js.map +1 -1
- package/build-module/block/edit.js +5 -3
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/edit.native.js +5 -3
- package/build-module/block/edit.native.js.map +1 -1
- package/build-module/calendar/edit.js +12 -4
- package/build-module/calendar/edit.js.map +1 -1
- package/build-module/columns/edit.native.js +3 -2
- package/build-module/columns/edit.native.js.map +1 -1
- package/build-module/cover/edit/resizable-cover.js +6 -0
- package/build-module/cover/edit/resizable-cover.js.map +1 -1
- package/build-module/group/transforms.js +5 -0
- package/build-module/group/transforms.js.map +1 -1
- package/build-module/index.native.js +16 -4
- package/build-module/index.native.js.map +1 -1
- package/build-module/list/index.js +1 -1
- package/build-module/list/index.js.map +1 -1
- package/build-module/list/v2/edit.js +15 -5
- package/build-module/list/v2/edit.js.map +1 -1
- package/build-module/list/v2/tag-name.js +21 -0
- package/build-module/list/v2/tag-name.js.map +1 -0
- package/build-module/list/v2/tag-name.native.js +21 -0
- package/build-module/list/v2/tag-name.native.js.map +1 -0
- package/build-module/list/v2/transforms.js +1 -10
- package/build-module/list/v2/transforms.js.map +1 -1
- package/build-module/list-item/edit.js +1 -3
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/edit.native.js +141 -0
- package/build-module/list-item/edit.native.js.map +1 -0
- package/build-module/list-item/icons.native.js +37 -0
- package/build-module/list-item/icons.native.js.map +1 -0
- package/build-module/list-item/list-style-type.native.js +124 -0
- package/build-module/list-item/list-style-type.native.js.map +1 -0
- package/build-module/media-text/deprecated.js +189 -65
- package/build-module/media-text/deprecated.js.map +1 -1
- package/build-module/media-text/edit.js +2 -1
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/media-container.js +1 -1
- package/build-module/media-text/media-container.js.map +1 -1
- package/build-module/navigation/edit/index.js +66 -122
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +12 -15
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +4 -2
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +12 -3
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js +5 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build-module/navigation/edit/use-inner-blocks.js +33 -0
- package/build-module/navigation/edit/use-inner-blocks.js.map +1 -0
- package/build-module/navigation/edit/utils.js +21 -0
- package/build-module/navigation/edit/utils.js.map +1 -0
- package/build-module/navigation/use-navigation-menu.js +7 -3
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/post-author/edit.js +5 -2
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-author-biography/edit.js +6 -1
- package/build-module/post-author-biography/edit.js.map +1 -1
- package/build-module/post-content/edit.js +5 -3
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +17 -3
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-featured-image/index.js +9 -0
- package/build-module/post-featured-image/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +42 -9
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +16 -12
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query-title/edit.js +20 -8
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/query-title/index.js +4 -0
- package/build-module/query-title/index.js.map +1 -1
- package/build-module/query-title/variations.js +10 -0
- package/build-module/query-title/variations.js.map +1 -1
- package/build-module/quote/transforms.js +3 -3
- package/build-module/quote/transforms.js.map +1 -1
- package/build-module/separator/edit.js +1 -1
- package/build-module/separator/edit.js.map +1 -1
- package/build-module/social-links/edit.js +1 -0
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/template-part/edit/index.js +5 -3
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-style/editor-rtl.css +10 -0
- package/build-style/editor.css +10 -0
- package/build-style/latest-posts/editor-rtl.css +3 -0
- package/build-style/latest-posts/editor.css +3 -0
- package/build-style/navigation/style-rtl.css +17 -19
- package/build-style/navigation/style.css +17 -19
- package/build-style/query/editor-rtl.css +7 -0
- package/build-style/query/editor.css +7 -0
- package/build-style/query-pagination/style-rtl.css +6 -0
- package/build-style/query-pagination/style.css +6 -0
- package/build-style/search/style-rtl.css +2 -0
- package/build-style/search/style.css +2 -0
- package/build-style/style-rtl.css +26 -19
- package/build-style/style.css +26 -19
- package/build-style/tag-cloud/style-rtl.css +1 -0
- package/build-style/tag-cloud/style.css +1 -0
- package/package.json +28 -29
- package/src/archives/block.json +4 -0
- package/src/archives/edit.js +12 -1
- package/src/archives/index.php +5 -3
- package/src/audio/test/__snapshots__/edit.native.js.snap +16 -2
- package/src/block/edit.js +4 -4
- package/src/block/edit.native.js +4 -4
- package/src/calendar/edit.js +11 -4
- package/src/columns/edit.native.js +4 -2
- package/src/cover/edit/resizable-cover.js +6 -0
- package/src/cover/index.php +2 -2
- package/src/file/test/__snapshots__/edit.native.js.snap +32 -4
- package/src/group/transforms.js +7 -0
- package/src/home-link/index.php +8 -17
- package/src/image/test/edit.native.js +6 -10
- package/src/index.native.js +15 -2
- package/src/latest-posts/editor.scss +5 -0
- package/src/list/index.js +1 -1
- package/src/list/test/__snapshots__/edit.native.js.snap +133 -0
- package/src/list/test/edit.native.js +511 -7
- package/src/list/v2/edit.js +12 -4
- package/src/list/v2/tag-name.js +13 -0
- package/src/list/v2/tag-name.native.js +12 -0
- package/src/list/v2/transforms.js +1 -9
- package/src/list-item/edit.js +1 -1
- package/src/list-item/edit.native.js +148 -0
- package/src/list-item/icons.native.js +34 -0
- package/src/list-item/list-style-type.native.js +139 -0
- package/src/list-item/style.native.scss +45 -0
- package/src/media-text/deprecated.js +561 -415
- package/src/media-text/edit.js +1 -0
- package/src/media-text/media-container.js +3 -1
- package/src/media-text/test/media-container.js +24 -0
- package/src/navigation/edit/index.js +83 -164
- package/src/navigation/edit/navigation-menu-selector.js +12 -26
- package/src/navigation/edit/placeholder/index.js +4 -2
- package/src/navigation/edit/responsive-wrapper.js +24 -3
- package/src/navigation/edit/use-create-navigation-menu.js +4 -0
- package/src/navigation/edit/use-inner-blocks.js +39 -0
- package/src/navigation/edit/utils.js +30 -0
- package/src/navigation/index.php +6 -0
- package/src/navigation/style.scss +12 -22
- package/src/navigation/use-navigation-menu.js +9 -5
- package/src/navigation-link/index.php +1 -1
- package/src/navigation-submenu/index.php +1 -1
- package/src/page-list/index.php +4 -4
- package/src/post-author/edit.js +6 -3
- package/src/post-author-biography/edit.js +4 -1
- package/src/post-content/edit.js +4 -4
- package/src/post-featured-image/block.json +9 -0
- package/src/post-featured-image/edit.js +23 -1
- package/src/post-featured-image/index.php +3 -1
- package/src/post-title/index.php +2 -1
- package/src/preformatted/test/__snapshots__/edit.native.js.snap +16 -2
- package/src/query/edit/inspector-controls/index.js +129 -65
- package/src/query/edit/inspector-controls/taxonomy-controls.js +17 -10
- package/src/query/editor.scss +9 -0
- package/src/query-pagination/style.scss +14 -0
- package/src/query-title/block.json +4 -0
- package/src/query-title/edit.js +33 -6
- package/src/query-title/index.php +17 -1
- package/src/query-title/variations.js +13 -0
- package/src/quote/transforms.js +3 -7
- package/src/search/style.scss +2 -0
- package/src/search/test/__snapshots__/edit.native.js.snap +56 -7
- package/src/separator/edit.js +1 -1
- package/src/separator/test/edit.js +5 -3
- package/src/site-title/index.php +8 -9
- package/src/social-link/index.php +1 -1
- package/src/social-links/edit.js +1 -0
- package/src/tag-cloud/style.scss +1 -0
- package/src/template-part/edit/index.js +4 -4
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function getComputedStyle( node ) {
|
|
2
|
+
return node.ownerDocument.defaultView.getComputedStyle( node );
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function detectColors(
|
|
6
|
+
colorsDetectionElement,
|
|
7
|
+
setColor,
|
|
8
|
+
setBackground
|
|
9
|
+
) {
|
|
10
|
+
if ( ! colorsDetectionElement ) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
setColor( getComputedStyle( colorsDetectionElement ).color );
|
|
14
|
+
|
|
15
|
+
let backgroundColorNode = colorsDetectionElement;
|
|
16
|
+
let backgroundColor =
|
|
17
|
+
getComputedStyle( backgroundColorNode ).backgroundColor;
|
|
18
|
+
while (
|
|
19
|
+
backgroundColor === 'rgba(0, 0, 0, 0)' &&
|
|
20
|
+
backgroundColorNode.parentNode &&
|
|
21
|
+
backgroundColorNode.parentNode.nodeType ===
|
|
22
|
+
backgroundColorNode.parentNode.ELEMENT_NODE
|
|
23
|
+
) {
|
|
24
|
+
backgroundColorNode = backgroundColorNode.parentNode;
|
|
25
|
+
backgroundColor =
|
|
26
|
+
getComputedStyle( backgroundColorNode ).backgroundColor;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
setBackground( backgroundColor );
|
|
30
|
+
}
|
package/src/navigation/index.php
CHANGED
|
@@ -472,6 +472,12 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
|
|
472
472
|
return '';
|
|
473
473
|
}
|
|
474
474
|
|
|
475
|
+
// Only published posts are valid. If this is changed then a corresponding change
|
|
476
|
+
// must also be implemented in `use-navigation-menu.js`.
|
|
477
|
+
if ( 'publish' !== $navigation_post->post_status ) {
|
|
478
|
+
return '';
|
|
479
|
+
}
|
|
480
|
+
|
|
475
481
|
$nav_menu_name = $navigation_post->post_title;
|
|
476
482
|
|
|
477
483
|
if ( isset( $seen_menu_names[ $nav_menu_name ] ) ) {
|
|
@@ -45,9 +45,6 @@ $navigation-icon-size: 24px;
|
|
|
45
45
|
// but still allow them to be overridden by user-set colors.
|
|
46
46
|
.wp-block-navigation-item__content {
|
|
47
47
|
display: block;
|
|
48
|
-
|
|
49
|
-
// Set the default menu item padding to zero, to allow text-only buttons.
|
|
50
|
-
padding: 0;
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
// The following rules provide class based application of user selected text
|
|
@@ -154,10 +151,7 @@ $navigation-icon-size: 24px;
|
|
|
154
151
|
// Styles for submenu flyout.
|
|
155
152
|
// These are separated out with reduced specificity to allow better inheritance from Global Styles.
|
|
156
153
|
.wp-block-navigation .has-child {
|
|
157
|
-
|
|
158
|
-
// That way if padding is set in theme.json, it still wins.
|
|
159
|
-
// https://css-tricks.com/almanac/selectors/w/where/
|
|
160
|
-
:where(.wp-block-navigation__submenu-container) {
|
|
154
|
+
.wp-block-navigation__submenu-container {
|
|
161
155
|
background-color: inherit;
|
|
162
156
|
color: inherit;
|
|
163
157
|
position: absolute;
|
|
@@ -233,7 +227,7 @@ $navigation-icon-size: 24px;
|
|
|
233
227
|
|
|
234
228
|
// Custom menu items.
|
|
235
229
|
// Show submenus on hover unless they open on click.
|
|
236
|
-
&:
|
|
230
|
+
&:not(.open-on-click):hover > .wp-block-navigation__submenu-container {
|
|
237
231
|
visibility: visible;
|
|
238
232
|
overflow: visible;
|
|
239
233
|
opacity: 1;
|
|
@@ -243,7 +237,7 @@ $navigation-icon-size: 24px;
|
|
|
243
237
|
}
|
|
244
238
|
|
|
245
239
|
// Keep submenus open when focus is within.
|
|
246
|
-
&:
|
|
240
|
+
&:not(.open-on-click):not(.open-on-hover-click):focus-within > .wp-block-navigation__submenu-container {
|
|
247
241
|
visibility: visible;
|
|
248
242
|
overflow: visible;
|
|
249
243
|
opacity: 1;
|
|
@@ -339,17 +333,6 @@ button.wp-block-navigation-item__content {
|
|
|
339
333
|
gap: inherit;
|
|
340
334
|
}
|
|
341
335
|
|
|
342
|
-
// Menu items with background.
|
|
343
|
-
// We use :where to keep specificity minimal, yet still scope it to only the navigation block.
|
|
344
|
-
// That way if padding is set in theme.json, it still wins.
|
|
345
|
-
// https://css-tricks.com/almanac/selectors/w/where/
|
|
346
|
-
.wp-block-navigation:where(.has-background) {
|
|
347
|
-
&,
|
|
348
|
-
.wp-block-navigation .wp-block-page-list,
|
|
349
|
-
.wp-block-navigation__container {
|
|
350
|
-
gap: inherit;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
336
|
|
|
354
337
|
/**
|
|
355
338
|
* Paddings
|
|
@@ -361,15 +344,18 @@ button.wp-block-navigation-item__content {
|
|
|
361
344
|
|
|
362
345
|
// When the menu has a background, items have paddings, reduce margins to compensate.
|
|
363
346
|
// Treat margins and paddings differently when the block has a background.
|
|
364
|
-
.wp-block-navigation
|
|
347
|
+
:where(.wp-block-navigation.has-background .wp-block-navigation-link a:not(.wp-element-button)),
|
|
348
|
+
:where(.wp-block-navigation.has-background .wp-block-navigation-submenu a:not(.wp-element-button)) {
|
|
365
349
|
padding: 0.5em 1em;
|
|
366
350
|
}
|
|
367
351
|
|
|
368
352
|
// Provide a default padding for submenus who should always have some, regardless of the top level menu items.
|
|
369
|
-
.wp-block-navigation
|
|
353
|
+
:where(.wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-link a:not(.wp-element-button)),
|
|
354
|
+
:where(.wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-submenu a:not(.wp-element-button)) {
|
|
370
355
|
padding: 0.5em 1em;
|
|
371
356
|
}
|
|
372
357
|
|
|
358
|
+
|
|
373
359
|
/**
|
|
374
360
|
* Justifications.
|
|
375
361
|
*/
|
|
@@ -452,6 +438,10 @@ button.wp-block-navigation-item__content {
|
|
|
452
438
|
right: 0;
|
|
453
439
|
bottom: 0;
|
|
454
440
|
|
|
441
|
+
.wp-block-navigation-link a {
|
|
442
|
+
color: inherit;
|
|
443
|
+
}
|
|
444
|
+
|
|
455
445
|
.wp-block-navigation__responsive-container-content {
|
|
456
446
|
display: flex;
|
|
457
447
|
flex-wrap: var(--navigation-layout-wrap, wrap);
|
|
@@ -99,15 +99,19 @@ function selectExistingMenu( select, ref ) {
|
|
|
99
99
|
args
|
|
100
100
|
);
|
|
101
101
|
|
|
102
|
+
// Only published Navigation posts are considered valid.
|
|
103
|
+
// If this is changed then a corresponding change must also be made
|
|
104
|
+
// in the index.php file.
|
|
105
|
+
const isNavigationMenuPublished = editedNavigationMenu.status === 'publish';
|
|
106
|
+
|
|
102
107
|
return {
|
|
103
108
|
isNavigationMenuResolved: hasResolvedNavigationMenu,
|
|
104
|
-
isNavigationMenuMissing:
|
|
109
|
+
isNavigationMenuMissing:
|
|
110
|
+
hasResolvedNavigationMenu &&
|
|
111
|
+
( ! navigationMenu || ! isNavigationMenuPublished ),
|
|
105
112
|
|
|
106
113
|
// getEditedEntityRecord will return the post regardless of status.
|
|
107
114
|
// Therefore if the found post is not published then we should ignore it.
|
|
108
|
-
navigationMenu:
|
|
109
|
-
editedNavigationMenu.status === 'publish'
|
|
110
|
-
? editedNavigationMenu
|
|
111
|
-
: null,
|
|
115
|
+
navigationMenu: isNavigationMenuPublished ? editedNavigationMenu : null,
|
|
112
116
|
};
|
|
113
117
|
}
|
|
@@ -150,7 +150,7 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
|
|
|
150
150
|
|
|
151
151
|
$css_classes = trim( implode( ' ', $classes ) );
|
|
152
152
|
$has_submenu = count( $block->inner_blocks ) > 0;
|
|
153
|
-
$is_active = ! empty( $attributes['id'] ) && ( get_the_ID() === $attributes['id'] );
|
|
153
|
+
$is_active = ! empty( $attributes['id'] ) && ( get_the_ID() === (int) $attributes['id'] );
|
|
154
154
|
|
|
155
155
|
$wrapper_attributes = get_block_wrapper_attributes(
|
|
156
156
|
array(
|
|
@@ -148,7 +148,7 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
|
|
|
148
148
|
|
|
149
149
|
$css_classes = trim( implode( ' ', $classes ) );
|
|
150
150
|
$has_submenu = count( $block->inner_blocks ) > 0;
|
|
151
|
-
$is_active = ! empty( $attributes['id'] ) && ( get_the_ID() === $attributes['id'] );
|
|
151
|
+
$is_active = ! empty( $attributes['id'] ) && ( get_the_ID() === (int) $attributes['id'] );
|
|
152
152
|
|
|
153
153
|
$show_submenu_indicators = isset( $block->context['showSubmenuIcon'] ) && $block->context['showSubmenuIcon'];
|
|
154
154
|
$open_on_click = isset( $block->context['openSubmenusOnClick'] ) && $block->context['openSubmenusOnClick'];
|
package/src/page-list/index.php
CHANGED
|
@@ -328,9 +328,9 @@ function render_block_core_page_list( $attributes, $content, $block ) {
|
|
|
328
328
|
);
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
331
|
+
/**
|
|
332
|
+
* Registers the `core/pages` block on server.
|
|
333
|
+
*/
|
|
334
334
|
function register_block_core_page_list() {
|
|
335
335
|
register_block_type_from_metadata(
|
|
336
336
|
__DIR__ . '/page-list',
|
|
@@ -339,4 +339,4 @@ function register_block_core_page_list() {
|
|
|
339
339
|
)
|
|
340
340
|
);
|
|
341
341
|
}
|
|
342
|
-
|
|
342
|
+
add_action( 'init', 'register_block_core_page_list' );
|
package/src/post-author/edit.js
CHANGED
|
@@ -162,9 +162,12 @@ function PostAuthorEdit( {
|
|
|
162
162
|
{ authorDetails?.name || __( 'Post Author' ) }
|
|
163
163
|
</p>
|
|
164
164
|
{ showBio && (
|
|
165
|
-
<p
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
<p
|
|
166
|
+
className="wp-block-post-author__bio"
|
|
167
|
+
dangerouslySetInnerHTML={ {
|
|
168
|
+
__html: authorDetails?.description,
|
|
169
|
+
} }
|
|
170
|
+
/>
|
|
168
171
|
) }
|
|
169
172
|
</div>
|
|
170
173
|
</div>
|
package/src/post-content/edit.js
CHANGED
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
useBlockProps,
|
|
8
8
|
useInnerBlocksProps,
|
|
9
9
|
useSetting,
|
|
10
|
-
|
|
10
|
+
__experimentalRecursionProvider as RecursionProvider,
|
|
11
|
+
__experimentalUseHasRecursion as useHasRecursion,
|
|
11
12
|
store as blockEditorStore,
|
|
12
13
|
Warning,
|
|
13
14
|
} from '@wordpress/block-editor';
|
|
@@ -118,15 +119,14 @@ function RecursionError() {
|
|
|
118
119
|
export default function PostContentEdit( { context, attributes } ) {
|
|
119
120
|
const { postId: contextPostId, postType: contextPostType } = context;
|
|
120
121
|
const { layout = {} } = attributes;
|
|
121
|
-
const
|
|
122
|
-
useNoRecursiveRenders( contextPostId );
|
|
122
|
+
const hasAlreadyRendered = useHasRecursion( contextPostId );
|
|
123
123
|
|
|
124
124
|
if ( contextPostId && contextPostType && hasAlreadyRendered ) {
|
|
125
125
|
return <RecursionError />;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
return (
|
|
129
|
-
<RecursionProvider>
|
|
129
|
+
<RecursionProvider uniqueId={ contextPostId }>
|
|
130
130
|
{ contextPostId && contextPostType ? (
|
|
131
131
|
<Content context={ context } layout={ layout } />
|
|
132
132
|
) : (
|
|
@@ -23,6 +23,15 @@
|
|
|
23
23
|
},
|
|
24
24
|
"sizeSlug": {
|
|
25
25
|
"type": "string"
|
|
26
|
+
},
|
|
27
|
+
"rel": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"attribute": "rel",
|
|
30
|
+
"default": ""
|
|
31
|
+
},
|
|
32
|
+
"linkTarget": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"default": "_self"
|
|
26
35
|
}
|
|
27
36
|
},
|
|
28
37
|
"usesContext": [ "postId", "postType", "queryId" ],
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
PanelBody,
|
|
10
10
|
Placeholder,
|
|
11
11
|
Button,
|
|
12
|
+
TextControl,
|
|
12
13
|
} from '@wordpress/components';
|
|
13
14
|
import {
|
|
14
15
|
InspectorControls,
|
|
@@ -53,7 +54,8 @@ function PostFeaturedImageDisplay( {
|
|
|
53
54
|
context: { postId, postType: postTypeSlug, queryId },
|
|
54
55
|
} ) {
|
|
55
56
|
const isDescendentOfQueryLoop = Number.isFinite( queryId );
|
|
56
|
-
const { isLink, height, width, scale, sizeSlug } =
|
|
57
|
+
const { isLink, height, width, scale, sizeSlug, rel, linkTarget } =
|
|
58
|
+
attributes;
|
|
57
59
|
const [ featuredImage, setFeaturedImage ] = useEntityProp(
|
|
58
60
|
'postType',
|
|
59
61
|
postTypeSlug,
|
|
@@ -128,6 +130,26 @@ function PostFeaturedImageDisplay( {
|
|
|
128
130
|
onChange={ () => setAttributes( { isLink: ! isLink } ) }
|
|
129
131
|
checked={ isLink }
|
|
130
132
|
/>
|
|
133
|
+
{ isLink && (
|
|
134
|
+
<>
|
|
135
|
+
<ToggleControl
|
|
136
|
+
label={ __( 'Open in new tab' ) }
|
|
137
|
+
onChange={ ( value ) =>
|
|
138
|
+
setAttributes( {
|
|
139
|
+
linkTarget: value ? '_blank' : '_self',
|
|
140
|
+
} )
|
|
141
|
+
}
|
|
142
|
+
checked={ linkTarget === '_blank' }
|
|
143
|
+
/>
|
|
144
|
+
<TextControl
|
|
145
|
+
label={ __( 'Link rel' ) }
|
|
146
|
+
value={ rel }
|
|
147
|
+
onChange={ ( newRel ) =>
|
|
148
|
+
setAttributes( { rel: newRel } )
|
|
149
|
+
}
|
|
150
|
+
/>
|
|
151
|
+
</>
|
|
152
|
+
) }
|
|
131
153
|
</PanelBody>
|
|
132
154
|
</InspectorControls>
|
|
133
155
|
</>
|
|
@@ -29,7 +29,9 @@ function render_block_core_post_featured_image( $attributes, $content, $block )
|
|
|
29
29
|
}
|
|
30
30
|
$wrapper_attributes = get_block_wrapper_attributes();
|
|
31
31
|
if ( $is_link ) {
|
|
32
|
-
$
|
|
32
|
+
$link_target = $attributes['linkTarget'];
|
|
33
|
+
$rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';
|
|
34
|
+
$featured_image = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', get_the_permalink( $post_ID ), esc_attr( $link_target ), $rel, $featured_image );
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
$has_width = ! empty( $attributes['width'] );
|
package/src/post-title/index.php
CHANGED
|
@@ -34,7 +34,8 @@ function render_block_core_post_title( $attributes, $content, $block ) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
|
|
37
|
-
$
|
|
37
|
+
$rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';
|
|
38
|
+
$title = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', get_the_permalink( $post_ID ), esc_attr( $attributes['linkTarget'] ), $rel, $title );
|
|
38
39
|
}
|
|
39
40
|
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
|
|
40
41
|
|
|
@@ -10,7 +10,14 @@ exports[`core/more/edit/native should match snapshot when content is empty 1`] =
|
|
|
10
10
|
]
|
|
11
11
|
}
|
|
12
12
|
>
|
|
13
|
-
<View
|
|
13
|
+
<View
|
|
14
|
+
style={
|
|
15
|
+
Array [
|
|
16
|
+
undefined,
|
|
17
|
+
undefined,
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
>
|
|
14
21
|
<TextInput
|
|
15
22
|
accessibilityLabel="Text input. Empty"
|
|
16
23
|
activeFormats={Array []}
|
|
@@ -50,7 +57,14 @@ exports[`core/more/edit/native should match snapshot when content is not empty 1
|
|
|
50
57
|
]
|
|
51
58
|
}
|
|
52
59
|
>
|
|
53
|
-
<View
|
|
60
|
+
<View
|
|
61
|
+
style={
|
|
62
|
+
Array [
|
|
63
|
+
undefined,
|
|
64
|
+
undefined,
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
>
|
|
54
68
|
<TextInput
|
|
55
69
|
accessibilityLabel="Text input. <pre>Hello World!</pre>"
|
|
56
70
|
activeFormats={Array []}
|
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
RangeControl,
|
|
14
14
|
ToggleControl,
|
|
15
15
|
Notice,
|
|
16
|
+
__experimentalToolsPanel as ToolsPanel,
|
|
17
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
16
18
|
} from '@wordpress/components';
|
|
17
19
|
import { __ } from '@wordpress/i18n';
|
|
18
20
|
import { InspectorControls } from '@wordpress/block-editor';
|
|
@@ -26,7 +28,7 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
26
28
|
import OrderControl from './order-control';
|
|
27
29
|
import AuthorControl from './author-control';
|
|
28
30
|
import ParentControl from './parent-control';
|
|
29
|
-
import TaxonomyControls from './taxonomy-controls';
|
|
31
|
+
import { TaxonomyControls, useTaxonomiesInfo } from './taxonomy-controls';
|
|
30
32
|
import StickyControl from './sticky-control';
|
|
31
33
|
import { usePostTypes } from '../../utils';
|
|
32
34
|
|
|
@@ -57,6 +59,7 @@ export default function QueryInspectorControls( {
|
|
|
57
59
|
} = query;
|
|
58
60
|
const [ showSticky, setShowSticky ] = useState( postType === 'post' );
|
|
59
61
|
const { postTypesTaxonomiesMap, postTypesSelectOptions } = usePostTypes();
|
|
62
|
+
const taxonomiesInfo = useTaxonomiesInfo( postType );
|
|
60
63
|
const isPostTypeHierarchical = useIsPostTypeHierarchical( postType );
|
|
61
64
|
useEffect( () => {
|
|
62
65
|
setShowSticky( postType === 'post' );
|
|
@@ -100,78 +103,139 @@ export default function QueryInspectorControls( {
|
|
|
100
103
|
return onChangeDebounced.cancel;
|
|
101
104
|
}, [ querySearch, onChangeDebounced ] );
|
|
102
105
|
return (
|
|
103
|
-
|
|
104
|
-
<
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'
|
|
109
|
-
) }
|
|
110
|
-
checked={ !! inherit }
|
|
111
|
-
onChange={ ( value ) => setQuery( { inherit: !! value } ) }
|
|
112
|
-
/>
|
|
113
|
-
{ ! inherit && (
|
|
114
|
-
<SelectControl
|
|
115
|
-
options={ postTypesSelectOptions }
|
|
116
|
-
value={ postType }
|
|
117
|
-
label={ __( 'Post type' ) }
|
|
118
|
-
onChange={ onPostTypeChange }
|
|
106
|
+
<>
|
|
107
|
+
<InspectorControls>
|
|
108
|
+
<PanelBody title={ __( 'Settings' ) }>
|
|
109
|
+
<ToggleControl
|
|
110
|
+
label={ __( 'Inherit query from template' ) }
|
|
119
111
|
help={ __(
|
|
120
|
-
'
|
|
112
|
+
'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'
|
|
121
113
|
) }
|
|
114
|
+
checked={ !! inherit }
|
|
115
|
+
onChange={ ( value ) =>
|
|
116
|
+
setQuery( { inherit: !! value } )
|
|
117
|
+
}
|
|
122
118
|
/>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
label={ __( '
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
min={ 2 }
|
|
133
|
-
max={ Math.max( 6, displayLayout.columns ) }
|
|
119
|
+
{ ! inherit && (
|
|
120
|
+
<SelectControl
|
|
121
|
+
options={ postTypesSelectOptions }
|
|
122
|
+
value={ postType }
|
|
123
|
+
label={ __( 'Post type' ) }
|
|
124
|
+
onChange={ onPostTypeChange }
|
|
125
|
+
help={ __(
|
|
126
|
+
'WordPress contains different types of content and they are divided into collections called "Post types". By default there are a few different ones such as blog posts and pages, but plugins could add more.'
|
|
127
|
+
) }
|
|
134
128
|
/>
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
) }
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
label={ __( 'Keyword' ) }
|
|
163
|
-
value={ querySearch }
|
|
164
|
-
onChange={ setQuerySearch }
|
|
165
|
-
/>
|
|
166
|
-
{ isPostTypeHierarchical && (
|
|
167
|
-
<ParentControl
|
|
168
|
-
parents={ parents }
|
|
169
|
-
postType={ postType }
|
|
129
|
+
) }
|
|
130
|
+
{ displayLayout?.type === 'flex' && (
|
|
131
|
+
<>
|
|
132
|
+
<RangeControl
|
|
133
|
+
label={ __( 'Columns' ) }
|
|
134
|
+
value={ displayLayout.columns }
|
|
135
|
+
onChange={ ( value ) =>
|
|
136
|
+
setDisplayLayout( { columns: value } )
|
|
137
|
+
}
|
|
138
|
+
min={ 2 }
|
|
139
|
+
max={ Math.max( 6, displayLayout.columns ) }
|
|
140
|
+
/>
|
|
141
|
+
{ displayLayout.columns > 6 && (
|
|
142
|
+
<Notice
|
|
143
|
+
status="warning"
|
|
144
|
+
isDismissible={ false }
|
|
145
|
+
>
|
|
146
|
+
{ __(
|
|
147
|
+
'This column count exceeds the recommended amount and may cause visual breakage.'
|
|
148
|
+
) }
|
|
149
|
+
</Notice>
|
|
150
|
+
) }
|
|
151
|
+
</>
|
|
152
|
+
) }
|
|
153
|
+
{ ! inherit && (
|
|
154
|
+
<OrderControl
|
|
155
|
+
{ ...{ order, orderBy } }
|
|
170
156
|
onChange={ setQuery }
|
|
171
157
|
/>
|
|
172
158
|
) }
|
|
159
|
+
{ ! inherit && showSticky && (
|
|
160
|
+
<StickyControl
|
|
161
|
+
value={ sticky }
|
|
162
|
+
onChange={ ( value ) =>
|
|
163
|
+
setQuery( { sticky: value } )
|
|
164
|
+
}
|
|
165
|
+
/>
|
|
166
|
+
) }
|
|
173
167
|
</PanelBody>
|
|
168
|
+
</InspectorControls>
|
|
169
|
+
{ ! inherit && (
|
|
170
|
+
<InspectorControls>
|
|
171
|
+
<ToolsPanel
|
|
172
|
+
className="block-library-query-toolspanel__filters"
|
|
173
|
+
label={ __( 'Filters' ) }
|
|
174
|
+
resetAll={ () => {
|
|
175
|
+
setQuery( {
|
|
176
|
+
author: '',
|
|
177
|
+
parents: [],
|
|
178
|
+
search: '',
|
|
179
|
+
taxQuery: null,
|
|
180
|
+
} );
|
|
181
|
+
setQuerySearch( '' );
|
|
182
|
+
} }
|
|
183
|
+
>
|
|
184
|
+
{ !! taxonomiesInfo?.length && (
|
|
185
|
+
<ToolsPanelItem
|
|
186
|
+
label={ __( 'Taxonomies' ) }
|
|
187
|
+
hasValue={ () =>
|
|
188
|
+
Object.values( taxQuery || {} ).some(
|
|
189
|
+
( terms ) => !! terms.length
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
onDeselect={ () =>
|
|
193
|
+
setQuery( { taxQuery: null } )
|
|
194
|
+
}
|
|
195
|
+
>
|
|
196
|
+
<TaxonomyControls
|
|
197
|
+
onChange={ setQuery }
|
|
198
|
+
query={ query }
|
|
199
|
+
/>
|
|
200
|
+
</ToolsPanelItem>
|
|
201
|
+
) }
|
|
202
|
+
<ToolsPanelItem
|
|
203
|
+
hasValue={ () => !! authorIds }
|
|
204
|
+
label={ __( 'Authors' ) }
|
|
205
|
+
onDeselect={ () => setQuery( { author: '' } ) }
|
|
206
|
+
>
|
|
207
|
+
<AuthorControl
|
|
208
|
+
value={ authorIds }
|
|
209
|
+
onChange={ setQuery }
|
|
210
|
+
/>
|
|
211
|
+
</ToolsPanelItem>
|
|
212
|
+
<ToolsPanelItem
|
|
213
|
+
hasValue={ () => !! querySearch }
|
|
214
|
+
label={ __( 'Keyword' ) }
|
|
215
|
+
onDeselect={ () => setQuerySearch( '' ) }
|
|
216
|
+
>
|
|
217
|
+
<TextControl
|
|
218
|
+
label={ __( 'Keyword' ) }
|
|
219
|
+
value={ querySearch }
|
|
220
|
+
onChange={ setQuerySearch }
|
|
221
|
+
/>
|
|
222
|
+
</ToolsPanelItem>
|
|
223
|
+
{ isPostTypeHierarchical && (
|
|
224
|
+
<ToolsPanelItem
|
|
225
|
+
hasValue={ () => !! parents?.length }
|
|
226
|
+
label={ __( 'Parents' ) }
|
|
227
|
+
onDeselect={ () => setQuery( { parents: [] } ) }
|
|
228
|
+
>
|
|
229
|
+
<ParentControl
|
|
230
|
+
parents={ parents }
|
|
231
|
+
postType={ postType }
|
|
232
|
+
onChange={ setQuery }
|
|
233
|
+
/>
|
|
234
|
+
</ToolsPanelItem>
|
|
235
|
+
) }
|
|
236
|
+
</ToolsPanel>
|
|
237
|
+
</InspectorControls>
|
|
174
238
|
) }
|
|
175
|
-
|
|
239
|
+
</>
|
|
176
240
|
);
|
|
177
241
|
}
|
|
@@ -33,8 +33,8 @@ const getTermIdByTermValue = ( termsMappedByName, termValue ) => {
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
const taxonomies = useTaxonomies(
|
|
36
|
+
export const useTaxonomiesInfo = ( postType ) => {
|
|
37
|
+
const taxonomies = useTaxonomies( postType );
|
|
38
38
|
const taxonomiesInfo = useSelect(
|
|
39
39
|
( select ) => {
|
|
40
40
|
const { getEntityRecords } = select( coreStore );
|
|
@@ -51,6 +51,11 @@ function TaxonomyControls( { onChange, query } ) {
|
|
|
51
51
|
},
|
|
52
52
|
[ taxonomies ]
|
|
53
53
|
);
|
|
54
|
+
return taxonomiesInfo;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export function TaxonomyControls( { onChange, query } ) {
|
|
58
|
+
const taxonomiesInfo = useTaxonomiesInfo( query.postType );
|
|
54
59
|
const onTermsChange = ( taxonomySlug ) => ( newTermValues ) => {
|
|
55
60
|
const taxonomyInfo = taxonomiesInfo.find(
|
|
56
61
|
( { slug } ) => slug === taxonomySlug
|
|
@@ -102,17 +107,19 @@ function TaxonomyControls( { onChange, query } ) {
|
|
|
102
107
|
return null;
|
|
103
108
|
}
|
|
104
109
|
return (
|
|
105
|
-
<
|
|
110
|
+
<div
|
|
106
111
|
key={ slug }
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
className="block-library-query-inspector__taxonomy-control"
|
|
113
|
+
>
|
|
114
|
+
<FormTokenField
|
|
115
|
+
label={ name }
|
|
116
|
+
value={ getExistingTaxQueryValue( slug ) }
|
|
117
|
+
suggestions={ terms.names }
|
|
118
|
+
onChange={ onTermsChange( slug ) }
|
|
119
|
+
/>
|
|
120
|
+
</div>
|
|
112
121
|
);
|
|
113
122
|
} ) }
|
|
114
123
|
</>
|
|
115
124
|
);
|
|
116
125
|
}
|
|
117
|
-
|
|
118
|
-
export default TaxonomyControls;
|
package/src/query/editor.scss
CHANGED
|
@@ -43,3 +43,12 @@
|
|
|
43
43
|
max-height: none;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
.block-library-query-toolspanel__filters {
|
|
48
|
+
.components-form-token-field__help {
|
|
49
|
+
margin-bottom: 0;
|
|
50
|
+
}
|
|
51
|
+
.block-library-query-inspector__taxonomy-control:not(:last-child) {
|
|
52
|
+
margin-bottom: $grid-unit-30;
|
|
53
|
+
}
|
|
54
|
+
}
|