@wordpress/block-library 9.20.0 → 9.22.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 +4 -0
- package/build/categories/edit.js +3 -3
- package/build/categories/edit.js.map +1 -1
- package/build/cover/index.js +1 -1
- package/build/cover/index.js.map +1 -1
- package/build/details/edit.js +1 -5
- package/build/details/edit.js.map +1 -1
- package/build/details/index.js +1 -1
- package/build/details/index.js.map +1 -1
- package/build/embed/edit.js +4 -1
- package/build/embed/edit.js.map +1 -1
- package/build/image/edit.js +3 -2
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +13 -8
- package/build/image/image.js.map +1 -1
- package/build/navigation/edit/index.js +8 -4
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/view.js +2 -1
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +27 -29
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/index.js +0 -3
- package/build/navigation-link/index.js.map +1 -1
- package/build/navigation-link/transforms.js +0 -2
- package/build/navigation-link/transforms.js.map +1 -1
- package/build/navigation-link/update-attributes.js +0 -1
- package/build/navigation-link/update-attributes.js.map +1 -1
- package/build/navigation-submenu/edit.js +1 -24
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/navigation-submenu/index.js +0 -3
- package/build/navigation-submenu/index.js.map +1 -1
- package/build/post-comments-count/index.js +0 -1
- package/build/post-comments-count/index.js.map +1 -1
- package/build/post-comments-link/index.js +0 -1
- package/build/post-comments-link/index.js.map +1 -1
- package/build/post-featured-image/edit.js +14 -3
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +47 -59
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/parent-control.js +2 -2
- package/build/query/edit/inspector-controls/parent-control.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +2 -2
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query/edit/query-content.js +4 -17
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query-total/index.js +3 -0
- package/build/query-total/index.js.map +1 -1
- package/build/quote/index.js +1 -1
- package/build/quote/index.js.map +1 -1
- package/build/rss/edit.js +21 -1
- package/build/rss/edit.js.map +1 -1
- package/build/rss/index.js +7 -0
- package/build/rss/index.js.map +1 -1
- package/build/site-title/edit.js +1 -1
- package/build/site-title/edit.js.map +1 -1
- package/build/social-links/edit.js +29 -31
- package/build/social-links/edit.js.map +1 -1
- package/build/table/index.js +3 -3
- package/build/table/index.js.map +1 -1
- package/build/table/transforms.js +11 -3
- package/build/table/transforms.js.map +1 -1
- package/build/table-of-contents/edit.js +50 -8
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/table-of-contents/hooks.js +13 -4
- package/build/table-of-contents/hooks.js.map +1 -1
- package/build/table-of-contents/index.js +3 -0
- package/build/table-of-contents/index.js.map +1 -1
- package/build-module/categories/edit.js +3 -3
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/cover/index.js +1 -1
- package/build-module/cover/index.js.map +1 -1
- package/build-module/details/edit.js +1 -5
- package/build-module/details/edit.js.map +1 -1
- package/build-module/details/index.js +1 -1
- package/build-module/details/index.js.map +1 -1
- package/build-module/embed/edit.js +4 -1
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/image/edit.js +3 -2
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +14 -9
- package/build-module/image/image.js.map +1 -1
- package/build-module/navigation/edit/index.js +8 -4
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/view.js +2 -1
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +28 -30
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/index.js +0 -3
- package/build-module/navigation-link/index.js.map +1 -1
- package/build-module/navigation-link/transforms.js +0 -2
- package/build-module/navigation-link/transforms.js.map +1 -1
- package/build-module/navigation-link/update-attributes.js +0 -1
- package/build-module/navigation-link/update-attributes.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +1 -24
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/navigation-submenu/index.js +0 -3
- package/build-module/navigation-submenu/index.js.map +1 -1
- package/build-module/post-comments-count/index.js +0 -1
- package/build-module/post-comments-count/index.js.map +1 -1
- package/build-module/post-comments-link/index.js +0 -1
- package/build-module/post-comments-link/index.js.map +1 -1
- package/build-module/post-featured-image/edit.js +14 -3
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +49 -61
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/parent-control.js +2 -2
- package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +2 -2
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query/edit/query-content.js +4 -17
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query-total/index.js +3 -0
- package/build-module/query-total/index.js.map +1 -1
- package/build-module/quote/index.js +1 -1
- package/build-module/quote/index.js.map +1 -1
- package/build-module/rss/edit.js +22 -2
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/rss/index.js +7 -0
- package/build-module/rss/index.js.map +1 -1
- package/build-module/site-title/edit.js +1 -1
- package/build-module/site-title/edit.js.map +1 -1
- package/build-module/social-links/edit.js +30 -32
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/table/index.js +3 -3
- package/build-module/table/index.js.map +1 -1
- package/build-module/table/transforms.js +11 -3
- package/build-module/table/transforms.js.map +1 -1
- package/build-module/table-of-contents/edit.js +52 -10
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/table-of-contents/hooks.js +13 -4
- package/build-module/table-of-contents/hooks.js.map +1 -1
- package/build-module/table-of-contents/index.js +3 -0
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-style/editor-rtl.css +1 -50
- package/build-style/editor.css +1 -50
- package/build-style/media-text/style-rtl.css +0 -2
- package/build-style/media-text/style.css +0 -2
- package/build-style/post-comments-form/style-rtl.css +3 -0
- package/build-style/post-comments-form/style.css +3 -0
- package/build-style/search/style-rtl.css +1 -0
- package/build-style/search/style.css +1 -0
- package/build-style/social-links/editor-rtl.css +1 -50
- package/build-style/social-links/editor.css +1 -50
- package/build-style/style-rtl.css +4 -6
- package/build-style/style.css +4 -6
- package/build-style/tag-cloud/style-rtl.css +0 -4
- package/build-style/tag-cloud/style.css +0 -4
- package/package.json +35 -35
- package/src/button/index.php +2 -3
- package/src/categories/edit.js +3 -3
- package/src/cover/index.js +1 -1
- package/src/details/edit.js +6 -8
- package/src/details/index.js +1 -1
- package/src/embed/edit.js +7 -1
- package/src/file/index.php +2 -3
- package/src/image/edit.js +3 -3
- package/src/image/image.js +9 -12
- package/src/latest-comments/index.php +1 -1
- package/src/latest-posts/index.php +3 -0
- package/src/media-text/style.scss +0 -2
- package/src/navigation/edit/index.js +4 -0
- package/src/navigation/index.php +1 -1
- package/src/navigation/view.js +2 -1
- package/src/navigation-link/block.json +0 -3
- package/src/navigation-link/edit.js +46 -33
- package/src/navigation-link/index.php +1 -5
- package/src/navigation-link/transforms.js +1 -2
- package/src/navigation-link/update-attributes.js +0 -1
- package/src/navigation-submenu/block.json +0 -3
- package/src/navigation-submenu/edit.js +1 -24
- package/src/navigation-submenu/index.php +0 -4
- package/src/post-comments-count/block.json +0 -1
- package/src/post-comments-count/index.php +4 -0
- package/src/post-comments-form/style.scss +5 -0
- package/src/post-comments-link/block.json +0 -1
- package/src/post-comments-link/index.php +4 -0
- package/src/post-featured-image/edit.js +93 -75
- package/src/query/edit/inspector-controls/index.js +66 -91
- package/src/query/edit/inspector-controls/parent-control.js +2 -2
- package/src/query/edit/inspector-controls/taxonomy-controls.js +2 -2
- package/src/query/edit/query-content.js +7 -16
- package/src/query-total/block.json +3 -0
- package/src/query-total/index.php +1 -1
- package/src/quote/index.js +1 -1
- package/src/rss/block.json +7 -0
- package/src/rss/edit.js +21 -0
- package/src/rss/index.php +27 -9
- package/src/search/index.php +12 -9
- package/src/search/style.scss +1 -0
- package/src/site-title/edit.js +1 -1
- package/src/site-title/index.php +1 -1
- package/src/social-links/edit.js +29 -30
- package/src/social-links/editor.scss +1 -59
- package/src/table/index.js +3 -3
- package/src/table/transforms.js +14 -2
- package/src/table-of-contents/block.json +3 -0
- package/src/table-of-contents/edit.js +45 -4
- package/src/table-of-contents/hooks.js +12 -3
- package/src/tag-cloud/style.scss +0 -5
package/src/image/edit.js
CHANGED
|
@@ -116,9 +116,9 @@ export function ImageEdit( {
|
|
|
116
116
|
// Only observe the max width from the parent container when the parent layout is not flex nor grid.
|
|
117
117
|
// This won't work for them because the container width changes with the image.
|
|
118
118
|
// TODO: Find a way to observe the container width for flex and grid layouts.
|
|
119
|
+
const layoutType = parentLayout?.type || parentLayout?.default?.type;
|
|
119
120
|
const isMaxWidthContainerWidth =
|
|
120
|
-
!
|
|
121
|
-
( parentLayout.type !== 'flex' && parentLayout.type !== 'grid' );
|
|
121
|
+
! layoutType || ( layoutType !== 'flex' && layoutType !== 'grid' );
|
|
122
122
|
const [ maxWidthObserver, maxContentWidth ] = useMaxWidthObserver();
|
|
123
123
|
|
|
124
124
|
const [ placeholderResizeListener, { width: placeholderWidth } ] =
|
|
@@ -452,7 +452,7 @@ export function ImageEdit( {
|
|
|
452
452
|
context={ context }
|
|
453
453
|
clientId={ clientId }
|
|
454
454
|
blockEditingMode={ blockEditingMode }
|
|
455
|
-
parentLayoutType={
|
|
455
|
+
parentLayoutType={ layoutType }
|
|
456
456
|
maxContentWidth={ maxContentWidth }
|
|
457
457
|
/>
|
|
458
458
|
<MediaPlaceholder
|
package/src/image/image.js
CHANGED
|
@@ -44,7 +44,7 @@ import { getFilename } from '@wordpress/url';
|
|
|
44
44
|
import { getBlockBindingsSource, switchToBlockType } from '@wordpress/blocks';
|
|
45
45
|
import { crop, overlayText, upload, chevronDown } from '@wordpress/icons';
|
|
46
46
|
import { store as noticesStore } from '@wordpress/notices';
|
|
47
|
-
import { store as coreStore
|
|
47
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Internal dependencies
|
|
@@ -301,7 +301,6 @@ export default function Image( {
|
|
|
301
301
|
}, [ imageElement ] );
|
|
302
302
|
const setRefs = useMergeRefs( [ setImageElement, setResizeObserved ] );
|
|
303
303
|
const { allowResize = true } = context;
|
|
304
|
-
const { getBlock, getSettings } = useSelect( blockEditorStore );
|
|
305
304
|
|
|
306
305
|
const image = useSelect(
|
|
307
306
|
( select ) =>
|
|
@@ -313,7 +312,7 @@ export default function Image( {
|
|
|
313
312
|
|
|
314
313
|
const { canInsertCover, imageEditing, imageSizes, maxWidth } = useSelect(
|
|
315
314
|
( select ) => {
|
|
316
|
-
const { getBlockRootClientId, canInsertBlockType } =
|
|
315
|
+
const { getBlockRootClientId, canInsertBlockType, getSettings } =
|
|
317
316
|
select( blockEditorStore );
|
|
318
317
|
|
|
319
318
|
const rootClientId = getBlockRootClientId( clientId );
|
|
@@ -331,10 +330,13 @@ export default function Image( {
|
|
|
331
330
|
},
|
|
332
331
|
[ clientId ]
|
|
333
332
|
);
|
|
333
|
+
const { getBlock, getSettings } = useSelect( blockEditorStore );
|
|
334
334
|
|
|
335
335
|
const { replaceBlocks, toggleSelection } = useDispatch( blockEditorStore );
|
|
336
336
|
const { createErrorNotice, createSuccessNotice } =
|
|
337
337
|
useDispatch( noticesStore );
|
|
338
|
+
const { editEntityRecord } = useDispatch( coreStore );
|
|
339
|
+
|
|
338
340
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
339
341
|
const isWideAligned = [ 'wide', 'full' ].includes( align );
|
|
340
342
|
const [
|
|
@@ -381,7 +383,7 @@ export default function Image( {
|
|
|
381
383
|
.then( ( blob ) => setExternalBlob( blob ) )
|
|
382
384
|
// Do nothing, cannot upload.
|
|
383
385
|
.catch( () => {} );
|
|
384
|
-
}, [ id, url, isSingleSelected, externalBlob ] );
|
|
386
|
+
}, [ id, url, isSingleSelected, externalBlob, getSettings ] );
|
|
385
387
|
|
|
386
388
|
// Get naturalWidth and naturalHeight from image, and fall back to loaded natural
|
|
387
389
|
// width and height. This resolves an issue in Safari where the loaded natural
|
|
@@ -891,13 +893,6 @@ export default function Image( {
|
|
|
891
893
|
const { postType, postId, queryId } = context;
|
|
892
894
|
const isDescendentOfQueryLoop = Number.isFinite( queryId );
|
|
893
895
|
|
|
894
|
-
const [ , setFeaturedImage ] = useEntityProp(
|
|
895
|
-
'postType',
|
|
896
|
-
postType,
|
|
897
|
-
'featured_media',
|
|
898
|
-
postId
|
|
899
|
-
);
|
|
900
|
-
|
|
901
896
|
let img =
|
|
902
897
|
temporaryURL && hasImageErrored ? (
|
|
903
898
|
// Show a placeholder during upload when the blob URL can't be loaded. This can
|
|
@@ -1103,7 +1098,9 @@ export default function Image( {
|
|
|
1103
1098
|
* Set the post's featured image with the current image.
|
|
1104
1099
|
*/
|
|
1105
1100
|
const setPostFeatureImage = () => {
|
|
1106
|
-
|
|
1101
|
+
editEntityRecord( 'postType', postType, postId, {
|
|
1102
|
+
featured_media: id,
|
|
1103
|
+
} );
|
|
1107
1104
|
createSuccessNotice( __( 'Post featured image updated.' ), {
|
|
1108
1105
|
type: 'snackbar',
|
|
1109
1106
|
} );
|
|
@@ -42,7 +42,7 @@ function wp_latest_comments_draft_or_post_title( $post = 0 ) {
|
|
|
42
42
|
*
|
|
43
43
|
* @return string Returns the post content with latest comments added.
|
|
44
44
|
*/
|
|
45
|
-
function render_block_core_latest_comments( $attributes
|
|
45
|
+
function render_block_core_latest_comments( $attributes ) {
|
|
46
46
|
$comments = get_comments(
|
|
47
47
|
/** This filter is documented in wp-includes/widgets/class-wp-widget-recent-comments.php */
|
|
48
48
|
apply_filters(
|
|
@@ -33,6 +33,9 @@ function block_core_latest_posts_get_excerpt_length() {
|
|
|
33
33
|
*
|
|
34
34
|
* @since 5.0.0
|
|
35
35
|
*
|
|
36
|
+
* @global WP_Post $post Global post object.
|
|
37
|
+
* @global int $block_core_latest_posts_excerpt_length Excerpt length set by the Latest Posts core block.
|
|
38
|
+
*
|
|
36
39
|
* @param array $attributes The block attributes.
|
|
37
40
|
*
|
|
38
41
|
* @return string Returns the post content with latest posts added.
|
|
@@ -106,7 +106,6 @@
|
|
|
106
106
|
|
|
107
107
|
/* Image fill for versions 8 and onwards */
|
|
108
108
|
.wp-block-media-text.is-image-fill-element > .wp-block-media-text__media {
|
|
109
|
-
position: relative;
|
|
110
109
|
height: 100%;
|
|
111
110
|
min-height: 250px;
|
|
112
111
|
}
|
|
@@ -117,7 +116,6 @@
|
|
|
117
116
|
}
|
|
118
117
|
|
|
119
118
|
.wp-block-media-text.is-image-fill-element > .wp-block-media-text__media img {
|
|
120
|
-
position: absolute;
|
|
121
119
|
width: 100%;
|
|
122
120
|
height: 100%;
|
|
123
121
|
object-fit: cover;
|
|
@@ -143,6 +143,7 @@ function ColorTools( {
|
|
|
143
143
|
onColorChange: setTextColor,
|
|
144
144
|
resetAllFilter: () => setTextColor(),
|
|
145
145
|
clearable: true,
|
|
146
|
+
enableAlpha: true,
|
|
146
147
|
},
|
|
147
148
|
{
|
|
148
149
|
colorValue: backgroundColor.color,
|
|
@@ -150,6 +151,7 @@ function ColorTools( {
|
|
|
150
151
|
onColorChange: setBackgroundColor,
|
|
151
152
|
resetAllFilter: () => setBackgroundColor(),
|
|
152
153
|
clearable: true,
|
|
154
|
+
enableAlpha: true,
|
|
153
155
|
},
|
|
154
156
|
{
|
|
155
157
|
colorValue: overlayTextColor.color,
|
|
@@ -157,6 +159,7 @@ function ColorTools( {
|
|
|
157
159
|
onColorChange: setOverlayTextColor,
|
|
158
160
|
resetAllFilter: () => setOverlayTextColor(),
|
|
159
161
|
clearable: true,
|
|
162
|
+
enableAlpha: true,
|
|
160
163
|
},
|
|
161
164
|
{
|
|
162
165
|
colorValue: overlayBackgroundColor.color,
|
|
@@ -164,6 +167,7 @@ function ColorTools( {
|
|
|
164
167
|
onColorChange: setOverlayBackgroundColor,
|
|
165
168
|
resetAllFilter: () => setOverlayBackgroundColor(),
|
|
166
169
|
clearable: true,
|
|
170
|
+
enableAlpha: true,
|
|
167
171
|
},
|
|
168
172
|
] }
|
|
169
173
|
panelId={ clientId }
|
package/src/navigation/index.php
CHANGED
|
@@ -819,7 +819,7 @@ function block_core_navigation_add_directives_to_submenu( $tags, $block_attribut
|
|
|
819
819
|
) ) {
|
|
820
820
|
// Add directives to the parent `<li>`.
|
|
821
821
|
$tags->set_attribute( 'data-wp-interactive', 'core/navigation' );
|
|
822
|
-
$tags->set_attribute( 'data-wp-context', '{ "submenuOpenedBy": { "click": false, "hover": false, "focus": false }, "type": "submenu", "modal": null }' );
|
|
822
|
+
$tags->set_attribute( 'data-wp-context', '{ "submenuOpenedBy": { "click": false, "hover": false, "focus": false }, "type": "submenu", "modal": null, "previousFocus": null }' );
|
|
823
823
|
$tags->set_attribute( 'data-wp-watch', 'callbacks.initMenu' );
|
|
824
824
|
$tags->set_attribute( 'data-wp-on--focusout', 'actions.handleMenuFocusout' );
|
|
825
825
|
$tags->set_attribute( 'data-wp-on--keydown', 'actions.handleMenuKeydown' );
|
package/src/navigation/view.js
CHANGED
|
@@ -116,7 +116,8 @@ const { state, actions } = store(
|
|
|
116
116
|
getContext();
|
|
117
117
|
if ( state.menuOpenedBy.click ) {
|
|
118
118
|
// If Escape close the menu.
|
|
119
|
-
if ( event
|
|
119
|
+
if ( event.key === 'Escape' ) {
|
|
120
|
+
event.stopPropagation(); // Keeps ancestor menus open.
|
|
120
121
|
actions.closeMenu( 'click' );
|
|
121
122
|
actions.closeMenu( 'focus' );
|
|
122
123
|
return;
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
store as blockEditorStore,
|
|
27
27
|
getColorClassName,
|
|
28
28
|
useInnerBlocksProps,
|
|
29
|
+
useBlockEditingMode,
|
|
29
30
|
} from '@wordpress/block-editor';
|
|
30
31
|
import { isURL, prependHTTP, safeDecodeURI } from '@wordpress/url';
|
|
31
32
|
import { useState, useEffect, useRef } from '@wordpress/element';
|
|
@@ -43,6 +44,10 @@ import { updateAttributes } from './update-attributes';
|
|
|
43
44
|
import { getColors } from '../navigation/edit/utils';
|
|
44
45
|
|
|
45
46
|
const DEFAULT_BLOCK = { name: 'core/navigation-link' };
|
|
47
|
+
const NESTING_BLOCK_NAMES = [
|
|
48
|
+
'core/navigation-link',
|
|
49
|
+
'core/navigation-submenu',
|
|
50
|
+
];
|
|
46
51
|
|
|
47
52
|
/**
|
|
48
53
|
* A React hook to determine if it's dragging within the target element.
|
|
@@ -95,19 +100,29 @@ const useIsDraggingWithin = ( elementRef ) => {
|
|
|
95
100
|
return isDraggingWithin;
|
|
96
101
|
};
|
|
97
102
|
|
|
98
|
-
const useIsInvalidLink = ( kind, type, id ) => {
|
|
103
|
+
const useIsInvalidLink = ( kind, type, id, enabled ) => {
|
|
99
104
|
const isPostType =
|
|
100
105
|
kind === 'post-type' || type === 'post' || type === 'page';
|
|
101
106
|
const hasId = Number.isInteger( id );
|
|
107
|
+
const blockEditingMode = useBlockEditingMode();
|
|
108
|
+
|
|
102
109
|
const postStatus = useSelect(
|
|
103
110
|
( select ) => {
|
|
104
111
|
if ( ! isPostType ) {
|
|
105
112
|
return null;
|
|
106
113
|
}
|
|
114
|
+
|
|
115
|
+
// Fetching the posts status is an "expensive" operation. Especially for sites with large navigations.
|
|
116
|
+
// When the block is rendered in a template or other disabled contexts we can skip this check in order
|
|
117
|
+
// to avoid all these additional requests that don't really add any value in that mode.
|
|
118
|
+
if ( blockEditingMode === 'disabled' || ! enabled ) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
|
|
107
122
|
const { getEntityRecord } = select( coreStore );
|
|
108
123
|
return getEntityRecord( 'postType', type, id )?.status;
|
|
109
124
|
},
|
|
110
|
-
[ isPostType, type, id ]
|
|
125
|
+
[ isPostType, blockEditingMode, enabled, type, id ]
|
|
111
126
|
);
|
|
112
127
|
|
|
113
128
|
// Check Navigation Link validity if:
|
|
@@ -159,7 +174,7 @@ function getMissingText( type ) {
|
|
|
159
174
|
* Consider reusing this components for both blocks.
|
|
160
175
|
*/
|
|
161
176
|
function Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) {
|
|
162
|
-
const { label, url, description,
|
|
177
|
+
const { label, url, description, rel } = attributes;
|
|
163
178
|
return (
|
|
164
179
|
<ToolsPanel label={ __( 'Settings' ) }>
|
|
165
180
|
<ToolsPanelItem
|
|
@@ -224,27 +239,6 @@ function Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) {
|
|
|
224
239
|
/>
|
|
225
240
|
</ToolsPanelItem>
|
|
226
241
|
|
|
227
|
-
<ToolsPanelItem
|
|
228
|
-
hasValue={ () => !! title }
|
|
229
|
-
label={ __( 'Title attribute' ) }
|
|
230
|
-
onDeselect={ () => setAttributes( { title: '' } ) }
|
|
231
|
-
isShownByDefault
|
|
232
|
-
>
|
|
233
|
-
<TextControl
|
|
234
|
-
__nextHasNoMarginBottom
|
|
235
|
-
__next40pxDefaultSize
|
|
236
|
-
label={ __( 'Title attribute' ) }
|
|
237
|
-
value={ title || '' }
|
|
238
|
-
onChange={ ( titleValue ) => {
|
|
239
|
-
setAttributes( { title: titleValue } );
|
|
240
|
-
} }
|
|
241
|
-
autoComplete="off"
|
|
242
|
-
help={ __(
|
|
243
|
-
'Additional information to help clarify the purpose of the link.'
|
|
244
|
-
) }
|
|
245
|
-
/>
|
|
246
|
-
</ToolsPanelItem>
|
|
247
|
-
|
|
248
242
|
<ToolsPanelItem
|
|
249
243
|
hasValue={ () => !! rel }
|
|
250
244
|
label={ __( 'Rel attribute' ) }
|
|
@@ -280,8 +274,6 @@ export default function NavigationLinkEdit( {
|
|
|
280
274
|
clientId,
|
|
281
275
|
} ) {
|
|
282
276
|
const { id, label, type, url, description, kind } = attributes;
|
|
283
|
-
|
|
284
|
-
const [ isInvalid, isDraft ] = useIsInvalidLink( kind, type, id );
|
|
285
277
|
const { maxNestingLevel } = context;
|
|
286
278
|
|
|
287
279
|
const {
|
|
@@ -313,6 +305,7 @@ export default function NavigationLinkEdit( {
|
|
|
313
305
|
isTopLevelLink,
|
|
314
306
|
isParentOfSelectedBlock,
|
|
315
307
|
hasChildren,
|
|
308
|
+
validateLinkStatus,
|
|
316
309
|
} = useSelect(
|
|
317
310
|
( select ) => {
|
|
318
311
|
const {
|
|
@@ -321,28 +314,48 @@ export default function NavigationLinkEdit( {
|
|
|
321
314
|
getBlockRootClientId,
|
|
322
315
|
hasSelectedInnerBlock,
|
|
323
316
|
getBlockParentsByBlockName,
|
|
317
|
+
getSelectedBlockClientId,
|
|
324
318
|
} = select( blockEditorStore );
|
|
319
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
320
|
+
const isTopLevel =
|
|
321
|
+
getBlockName( rootClientId ) === 'core/navigation';
|
|
322
|
+
const selectedBlockClientId = getSelectedBlockClientId();
|
|
323
|
+
const rootNavigationClientId = isTopLevel
|
|
324
|
+
? rootClientId
|
|
325
|
+
: getBlockParentsByBlockName(
|
|
326
|
+
clientId,
|
|
327
|
+
'core/navigation'
|
|
328
|
+
)[ 0 ];
|
|
329
|
+
|
|
330
|
+
// Enable when the root Navigation block is selected or any of its inner blocks.
|
|
331
|
+
const enableLinkStatusValidation =
|
|
332
|
+
selectedBlockClientId === rootNavigationClientId ||
|
|
333
|
+
hasSelectedInnerBlock( rootNavigationClientId, true );
|
|
325
334
|
|
|
326
335
|
return {
|
|
327
336
|
isAtMaxNesting:
|
|
328
|
-
getBlockParentsByBlockName( clientId,
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
] ).length >= maxNestingLevel,
|
|
332
|
-
isTopLevelLink:
|
|
333
|
-
getBlockName( getBlockRootClientId( clientId ) ) ===
|
|
334
|
-
'core/navigation',
|
|
337
|
+
getBlockParentsByBlockName( clientId, NESTING_BLOCK_NAMES )
|
|
338
|
+
.length >= maxNestingLevel,
|
|
339
|
+
isTopLevelLink: isTopLevel,
|
|
335
340
|
isParentOfSelectedBlock: hasSelectedInnerBlock(
|
|
336
341
|
clientId,
|
|
337
342
|
true
|
|
338
343
|
),
|
|
339
344
|
hasChildren: !! getBlockCount( clientId ),
|
|
345
|
+
validateLinkStatus: enableLinkStatusValidation,
|
|
340
346
|
};
|
|
341
347
|
},
|
|
342
348
|
[ clientId, maxNestingLevel ]
|
|
343
349
|
);
|
|
344
350
|
const { getBlocks } = useSelect( blockEditorStore );
|
|
345
351
|
|
|
352
|
+
const [ isInvalid, isDraft ] = useIsInvalidLink(
|
|
353
|
+
kind,
|
|
354
|
+
type,
|
|
355
|
+
id,
|
|
356
|
+
validateLinkStatus
|
|
357
|
+
);
|
|
358
|
+
|
|
346
359
|
/**
|
|
347
360
|
* Transform to submenu block.
|
|
348
361
|
*/
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @param array $context Navigation block context.
|
|
15
15
|
* @param array $attributes Block attributes.
|
|
16
|
-
* @param bool $is_sub_menu Whether the link is part of a sub-menu.
|
|
16
|
+
* @param bool $is_sub_menu Whether the link is part of a sub-menu. Default false.
|
|
17
17
|
* @return array Colors CSS classes and inline styles.
|
|
18
18
|
*/
|
|
19
19
|
function block_core_navigation_link_build_css_colors( $context, $attributes, $is_sub_menu = false ) {
|
|
@@ -249,10 +249,6 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
|
|
|
249
249
|
$html .= ' rel="nofollow"';
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
if ( isset( $attributes['title'] ) ) {
|
|
253
|
-
$html .= ' title="' . esc_attr( $attributes['title'] ) . '"';
|
|
254
|
-
}
|
|
255
|
-
|
|
256
252
|
// End appending HTML attributes to anchor tag.
|
|
257
253
|
|
|
258
254
|
// Start anchor tag content.
|
|
@@ -115,13 +115,12 @@ const transforms = {
|
|
|
115
115
|
{
|
|
116
116
|
type: 'block',
|
|
117
117
|
blocks: [ 'core/buttons' ],
|
|
118
|
-
transform: ( { label, url, rel,
|
|
118
|
+
transform: ( { label, url, rel, opensInNewTab } ) => {
|
|
119
119
|
return createBlock( 'core/buttons', {}, [
|
|
120
120
|
createBlock( 'core/button', {
|
|
121
121
|
text: label,
|
|
122
122
|
url,
|
|
123
123
|
rel,
|
|
124
|
-
title,
|
|
125
124
|
linkTarget: opensInNewTab ? '_blank' : undefined,
|
|
126
125
|
} ),
|
|
127
126
|
] );
|
|
@@ -19,7 +19,6 @@ import { safeDecodeURI } from '@wordpress/url';
|
|
|
19
19
|
* @property {number} [id] A post or term id.
|
|
20
20
|
* @property {boolean} [opensInNewTab] Sets link target to _blank when true.
|
|
21
21
|
* @property {string} [url] Link href.
|
|
22
|
-
* @property {string} [title] Link title attribute.
|
|
23
22
|
*/
|
|
24
23
|
/**
|
|
25
24
|
* Link Control onChange handler that updates block attributes when a setting is changed.
|
|
@@ -123,7 +123,6 @@ const useIsDraggingWithin = ( elementRef ) => {
|
|
|
123
123
|
* @property {number} [id] A post or term id.
|
|
124
124
|
* @property {boolean} [opensInNewTab] Sets link target to _blank when true.
|
|
125
125
|
* @property {string} [url] Link href.
|
|
126
|
-
* @property {string} [title] Link title attribute.
|
|
127
126
|
*/
|
|
128
127
|
|
|
129
128
|
export default function NavigationSubmenuEdit( {
|
|
@@ -135,7 +134,7 @@ export default function NavigationSubmenuEdit( {
|
|
|
135
134
|
context,
|
|
136
135
|
clientId,
|
|
137
136
|
} ) {
|
|
138
|
-
const { label, url, description, rel
|
|
137
|
+
const { label, url, description, rel } = attributes;
|
|
139
138
|
|
|
140
139
|
const { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context;
|
|
141
140
|
|
|
@@ -392,7 +391,6 @@ export default function NavigationSubmenuEdit( {
|
|
|
392
391
|
label: '',
|
|
393
392
|
url: '',
|
|
394
393
|
description: '',
|
|
395
|
-
title: '',
|
|
396
394
|
rel: '',
|
|
397
395
|
} );
|
|
398
396
|
} }
|
|
@@ -458,27 +456,6 @@ export default function NavigationSubmenuEdit( {
|
|
|
458
456
|
/>
|
|
459
457
|
</ToolsPanelItem>
|
|
460
458
|
|
|
461
|
-
<ToolsPanelItem
|
|
462
|
-
label={ __( 'Title attribute' ) }
|
|
463
|
-
isShownByDefault
|
|
464
|
-
hasValue={ () => !! title }
|
|
465
|
-
onDeselect={ () => setAttributes( { title: '' } ) }
|
|
466
|
-
>
|
|
467
|
-
<TextControl
|
|
468
|
-
__nextHasNoMarginBottom
|
|
469
|
-
__next40pxDefaultSize
|
|
470
|
-
value={ title || '' }
|
|
471
|
-
onChange={ ( titleValue ) => {
|
|
472
|
-
setAttributes( { title: titleValue } );
|
|
473
|
-
} }
|
|
474
|
-
label={ __( 'Title attribute' ) }
|
|
475
|
-
autoComplete="off"
|
|
476
|
-
help={ __(
|
|
477
|
-
'Additional information to help clarify the purpose of the link.'
|
|
478
|
-
) }
|
|
479
|
-
/>
|
|
480
|
-
</ToolsPanelItem>
|
|
481
|
-
|
|
482
459
|
<ToolsPanelItem
|
|
483
460
|
label={ __( 'Rel attribute' ) }
|
|
484
461
|
isShownByDefault
|
|
@@ -169,10 +169,6 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
|
|
|
169
169
|
$html .= ' rel="nofollow"';
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
if ( isset( $attributes['title'] ) ) {
|
|
173
|
-
$html .= ' title="' . esc_attr( $attributes['title'] ) . '"';
|
|
174
|
-
}
|
|
175
|
-
|
|
176
172
|
$html .= '>';
|
|
177
173
|
// End appending HTML attributes to anchor tag.
|
|
178
174
|
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/post-comments-count` block on the server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.9.0
|
|
12
|
+
*
|
|
11
13
|
* @param array $attributes Block attributes.
|
|
12
14
|
* @param string $content Block default content.
|
|
13
15
|
* @param WP_Block $block Block instance.
|
|
@@ -33,6 +35,8 @@ function render_block_core_post_comments_count( $attributes, $content, $block )
|
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
37
|
* Registers the `core/post-comments-count` block on the server.
|
|
38
|
+
*
|
|
39
|
+
* @since 6.9.0
|
|
36
40
|
*/
|
|
37
41
|
function register_block_core_post_comments_count() {
|
|
38
42
|
register_block_type_from_metadata(
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/post-comments-link` block on the server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.9.0
|
|
12
|
+
*
|
|
11
13
|
* @param array $attributes Block attributes.
|
|
12
14
|
* @param string $content Block default content.
|
|
13
15
|
* @param WP_Block $block Block instance.
|
|
@@ -59,6 +61,8 @@ function render_block_core_post_comments_link( $attributes, $content, $block ) {
|
|
|
59
61
|
|
|
60
62
|
/**
|
|
61
63
|
* Registers the `core/post-comments-link` block on the server.
|
|
64
|
+
*
|
|
65
|
+
* @since 6.9.0
|
|
62
66
|
*/
|
|
63
67
|
function register_block_core_post_comments_link() {
|
|
64
68
|
register_block_type_from_metadata(
|