@wordpress/block-library 9.41.0 → 9.41.1-next.v.202603102151.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/build/html/block.json +2 -1
- package/build/html/modal.cjs +142 -147
- package/build/html/modal.cjs.map +3 -3
- package/build/icon/block.json +3 -12
- package/build/image/image.cjs +5 -9
- package/build/image/image.cjs.map +2 -2
- package/build/navigation/edit/index.cjs +20 -14
- package/build/navigation/edit/index.cjs.map +3 -3
- package/build/navigation/view.cjs +9 -2
- package/build/navigation/view.cjs.map +2 -2
- package/build/navigation-link/block.json +5 -0
- package/build/paragraph/edit.cjs +1 -1
- package/build/paragraph/edit.cjs.map +1 -1
- package/build/playlist/edit.cjs +3 -23
- package/build/playlist/edit.cjs.map +3 -3
- package/build/playlist/utils.cjs +48 -0
- package/build/playlist/utils.cjs.map +7 -0
- package/build/post-excerpt/block.json +1 -3
- package/build/post-excerpt/deprecated.cjs +112 -0
- package/build/post-excerpt/deprecated.cjs.map +7 -0
- package/build/post-excerpt/edit.cjs +11 -30
- package/build/post-excerpt/edit.cjs.map +3 -3
- package/build/post-excerpt/index.cjs +3 -1
- package/build/post-excerpt/index.cjs.map +3 -3
- package/build/private-apis.cjs +3 -1
- package/build/private-apis.cjs.map +2 -2
- package/build/shortcode/block.json +2 -1
- package/build/template-part/edit/index.cjs +6 -4
- package/build/template-part/edit/index.cjs.map +2 -2
- package/build-module/html/block.json +2 -1
- package/build-module/html/modal.mjs +144 -149
- package/build-module/html/modal.mjs.map +2 -2
- package/build-module/icon/block.json +3 -12
- package/build-module/image/image.mjs +5 -9
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/navigation/edit/index.mjs +21 -14
- package/build-module/navigation/edit/index.mjs.map +2 -2
- package/build-module/navigation/view.mjs +9 -2
- package/build-module/navigation/view.mjs.map +2 -2
- package/build-module/navigation-link/block.json +5 -0
- package/build-module/paragraph/edit.mjs +2 -2
- package/build-module/paragraph/edit.mjs.map +1 -1
- package/build-module/playlist/edit.mjs +2 -18
- package/build-module/playlist/edit.mjs.map +2 -2
- package/build-module/playlist/utils.mjs +23 -0
- package/build-module/playlist/utils.mjs.map +7 -0
- package/build-module/post-excerpt/block.json +1 -3
- package/build-module/post-excerpt/deprecated.mjs +81 -0
- package/build-module/post-excerpt/deprecated.mjs.map +7 -0
- package/build-module/post-excerpt/edit.mjs +12 -34
- package/build-module/post-excerpt/edit.mjs.map +2 -2
- package/build-module/post-excerpt/index.mjs +3 -1
- package/build-module/post-excerpt/index.mjs.map +2 -2
- package/build-module/private-apis.mjs +3 -1
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/shortcode/block.json +2 -1
- package/build-module/template-part/edit/index.mjs +6 -4
- package/build-module/template-part/edit/index.mjs.map +2 -2
- package/build-style/common-rtl.css +1 -0
- package/build-style/common.css +1 -0
- package/build-style/editor-rtl.css +10 -6
- package/build-style/editor.css +10 -6
- package/build-style/html/editor-rtl.css +10 -6
- package/build-style/html/editor.css +10 -6
- package/build-style/navigation/style-rtl.css +11 -1
- package/build-style/navigation/style.css +11 -1
- package/build-style/playlist/style-rtl.css +4 -0
- package/build-style/playlist/style.css +4 -0
- package/build-style/style-rtl.css +16 -1
- package/build-style/style.css +16 -1
- package/package.json +38 -38
- package/src/accordion-item/index.php +17 -5
- package/src/common.scss +1 -0
- package/src/cover/index.php +8 -0
- package/src/details/index.php +47 -0
- package/src/html/block.json +2 -1
- package/src/html/editor.scss +15 -5
- package/src/html/modal.js +26 -22
- package/src/icon/block.json +3 -12
- package/src/image/image.js +8 -13
- package/src/navigation/edit/index.js +24 -14
- package/src/navigation/index.php +27 -2
- package/src/navigation/style.scss +7 -1
- package/src/navigation/view.js +14 -2
- package/src/navigation-link/block.json +5 -0
- package/src/navigation-link/index.php +1 -1
- package/src/paragraph/edit.js +2 -2
- package/src/playlist/edit.js +1 -34
- package/src/playlist/style.scss +5 -0
- package/src/playlist/test/edit.js +1 -1
- package/src/playlist/utils.js +42 -0
- package/src/post-excerpt/block.json +1 -3
- package/src/post-excerpt/deprecated.js +84 -0
- package/src/post-excerpt/edit.js +14 -39
- package/src/post-excerpt/index.js +2 -0
- package/src/private-apis.js +2 -0
- package/src/shortcode/block.json +2 -1
- package/src/template-part/edit/index.js +5 -1
package/src/navigation/index.php
CHANGED
|
@@ -710,6 +710,12 @@ class WP_Navigation_Block_Renderer {
|
|
|
710
710
|
$tags = new WP_HTML_Tag_Processor( $overlay_blocks_html );
|
|
711
711
|
$overlay_blocks_html = block_core_navigation_add_directives_to_overlay_close( $tags );
|
|
712
712
|
}
|
|
713
|
+
// Images in the overlay are hidden until the menu is opened. Pre-set
|
|
714
|
+
// fetchpriority="low" so that when wp_filter_content_tags() processes the
|
|
715
|
+
// parent template part, it sees the attribute already present and calls
|
|
716
|
+
// wp_get_loading_optimization_attributes() with fetchpriority="low", which both prevents
|
|
717
|
+
// fetchpriority="high" from being added and stops the LCP counter from being incremented.
|
|
718
|
+
$overlay_blocks_html = block_core_navigation_set_overlay_image_fetch_priority( $overlay_blocks_html );
|
|
713
719
|
}
|
|
714
720
|
|
|
715
721
|
$has_custom_overlay = ! empty( $overlay_blocks_html );
|
|
@@ -1111,6 +1117,25 @@ function block_core_navigation_add_directives_to_overlay_close( $tags ) {
|
|
|
1111
1117
|
return $tags->get_updated_html();
|
|
1112
1118
|
}
|
|
1113
1119
|
|
|
1120
|
+
/**
|
|
1121
|
+
* Sets fetchpriority="low" on all IMG tags within the navigation overlay.
|
|
1122
|
+
*
|
|
1123
|
+
* Images in the overlay are hidden until the menu is opened, so they should
|
|
1124
|
+
* not compete with any actual LCP element image on the page.
|
|
1125
|
+
*
|
|
1126
|
+
* @since 7.0.0
|
|
1127
|
+
*
|
|
1128
|
+
* @param string $overlay_blocks_html The rendered HTML of the overlay blocks.
|
|
1129
|
+
* @return string Modified HTML with fetchpriority="low" on all IMG tags.
|
|
1130
|
+
*/
|
|
1131
|
+
function block_core_navigation_set_overlay_image_fetch_priority( string $overlay_blocks_html ): string {
|
|
1132
|
+
$tags = new WP_HTML_Tag_Processor( $overlay_blocks_html );
|
|
1133
|
+
while ( $tags->next_tag( 'IMG' ) ) {
|
|
1134
|
+
$tags->set_attribute( 'fetchpriority', 'low' );
|
|
1135
|
+
}
|
|
1136
|
+
return $tags->get_updated_html();
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1114
1139
|
/**
|
|
1115
1140
|
* Add Interactivity API directives to the navigation-submenu and page-list
|
|
1116
1141
|
* blocks markup using the Tag Processor.
|
|
@@ -1146,8 +1171,8 @@ function block_core_navigation_add_directives_to_submenu( $tags, $block_attribut
|
|
|
1146
1171
|
$open_on_hover = 'hover' === $computed_visibility;
|
|
1147
1172
|
|
|
1148
1173
|
if ( $open_on_hover ) {
|
|
1149
|
-
$tags->set_attribute( 'data-wp-on--
|
|
1150
|
-
$tags->set_attribute( 'data-wp-on--
|
|
1174
|
+
$tags->set_attribute( 'data-wp-on--pointerenter', 'actions.openMenuOnHover' );
|
|
1175
|
+
$tags->set_attribute( 'data-wp-on--pointerleave', 'actions.closeMenuOnHover' );
|
|
1151
1176
|
}
|
|
1152
1177
|
|
|
1153
1178
|
// Add directives to the toggle submenu button.
|
|
@@ -247,7 +247,13 @@ $navigation-icon-size: 24px;
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
// Show submenus on hover unless they open on click.
|
|
250
|
-
|
|
250
|
+
// Restricted to true-hover devices to prevent sticky touch-hover on mobile.
|
|
251
|
+
@media (hover: hover) {
|
|
252
|
+
&:not(.open-on-click):hover > .wp-block-navigation__submenu-container {
|
|
253
|
+
@include show-submenu;
|
|
254
|
+
min-width: 200px;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
251
257
|
// Keep submenus open when focus is within.
|
|
252
258
|
&:not(.open-on-click):not(.open-on-hover-click):focus-within > .wp-block-navigation__submenu-container,
|
|
253
259
|
// Show submenus on click.
|
package/src/navigation/view.js
CHANGED
|
@@ -82,7 +82,12 @@ const { state, actions } = store(
|
|
|
82
82
|
},
|
|
83
83
|
},
|
|
84
84
|
actions: {
|
|
85
|
-
openMenuOnHover() {
|
|
85
|
+
openMenuOnHover( event ) {
|
|
86
|
+
// Pointer events from touch should not open the submenu on hover;
|
|
87
|
+
// touch devices toggle via the click action instead.
|
|
88
|
+
if ( event?.pointerType === 'touch' ) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
86
91
|
const { type, overlayOpenedBy } = getContext();
|
|
87
92
|
if (
|
|
88
93
|
type === 'submenu' &&
|
|
@@ -93,7 +98,10 @@ const { state, actions } = store(
|
|
|
93
98
|
actions.openMenu( 'hover' );
|
|
94
99
|
}
|
|
95
100
|
},
|
|
96
|
-
closeMenuOnHover() {
|
|
101
|
+
closeMenuOnHover( event ) {
|
|
102
|
+
if ( event?.pointerType === 'touch' ) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
97
105
|
const { type, overlayOpenedBy } = getContext();
|
|
98
106
|
if (
|
|
99
107
|
type === 'submenu' &&
|
|
@@ -128,6 +136,10 @@ const { state, actions } = store(
|
|
|
128
136
|
if ( menuOpenedBy.click || menuOpenedBy.focus ) {
|
|
129
137
|
actions.closeMenu( 'click' );
|
|
130
138
|
actions.closeMenu( 'focus' );
|
|
139
|
+
// Also clear hover in case it was set by a synthetic pointerenter
|
|
140
|
+
// on touch (e.g. the browser-fired mouseenter-equivalent before
|
|
141
|
+
// the click event), ensuring the submenu fully closes.
|
|
142
|
+
actions.closeMenu( 'hover' );
|
|
131
143
|
} else {
|
|
132
144
|
ctx.previousFocus = ref;
|
|
133
145
|
actions.openMenu( 'click' );
|
|
@@ -485,4 +485,4 @@ add_action( 'init', 'register_block_core_navigation_link' );
|
|
|
485
485
|
* Creates all variations for post types / taxonomies dynamically (= each time when variations are requested).
|
|
486
486
|
* Do not use variation_callback, to also account for unregistering post types/taxonomies later on.
|
|
487
487
|
*/
|
|
488
|
-
|
|
488
|
+
add_filter( 'get_block_type_variations', 'block_core_navigation_link_filter_variations', 10, 2 );
|
package/src/paragraph/edit.js
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
useBlockEditingMode,
|
|
22
22
|
} from '@wordpress/block-editor';
|
|
23
23
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
24
|
-
import {
|
|
24
|
+
import { formatLTR } from '@wordpress/icons';
|
|
25
25
|
/**
|
|
26
26
|
* Internal dependencies
|
|
27
27
|
*/
|
|
@@ -32,7 +32,7 @@ function ParagraphRTLControl( { direction, setDirection } ) {
|
|
|
32
32
|
return (
|
|
33
33
|
isRTL() && (
|
|
34
34
|
<ToolbarButton
|
|
35
|
-
icon={
|
|
35
|
+
icon={ formatLTR }
|
|
36
36
|
title={ _x( 'Left to right', 'editor button' ) }
|
|
37
37
|
isActive={ direction === 'ltr' }
|
|
38
38
|
onClick={ () => {
|
package/src/playlist/edit.js
CHANGED
|
@@ -38,42 +38,10 @@ import { createBlock } from '@wordpress/blocks';
|
|
|
38
38
|
import { Caption } from '../utils/caption';
|
|
39
39
|
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
|
|
40
40
|
import { WaveformPlayer } from '../utils/waveform-player';
|
|
41
|
+
import { getTrackAttributes } from './utils';
|
|
41
42
|
|
|
42
43
|
const ALLOWED_MEDIA_TYPES = [ 'audio' ];
|
|
43
44
|
|
|
44
|
-
/**
|
|
45
|
-
* Transform media library data into track block attributes.
|
|
46
|
-
*
|
|
47
|
-
* @param {Object} media - Media object from the media library.
|
|
48
|
-
* @return {Object} Track attributes for the playlist-track block.
|
|
49
|
-
*/
|
|
50
|
-
function getTrackAttributes( media ) {
|
|
51
|
-
return {
|
|
52
|
-
id: media.id || media.url, // Attachment ID or URL.
|
|
53
|
-
uniqueId: uuid(), // Unique ID for the track.
|
|
54
|
-
src: media.url,
|
|
55
|
-
title: media.title,
|
|
56
|
-
artist:
|
|
57
|
-
media.artist ||
|
|
58
|
-
media?.meta?.artist ||
|
|
59
|
-
media?.media_details?.artist ||
|
|
60
|
-
__( 'Unknown artist' ),
|
|
61
|
-
album:
|
|
62
|
-
media.album ||
|
|
63
|
-
media?.meta?.album ||
|
|
64
|
-
media?.media_details?.album ||
|
|
65
|
-
__( 'Unknown album' ),
|
|
66
|
-
length: media?.fileLength || media?.media_details?.length_formatted,
|
|
67
|
-
// Prevent using the default media attachment icon as the track image.
|
|
68
|
-
// Note: Image is not available when a new track is uploaded.
|
|
69
|
-
image:
|
|
70
|
-
media?.image?.src &&
|
|
71
|
-
media?.image?.src.endsWith( '/images/media/audio.svg' )
|
|
72
|
-
? ''
|
|
73
|
-
: media?.image?.src,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
45
|
const PlaylistEdit = ( {
|
|
78
46
|
attributes,
|
|
79
47
|
setAttributes,
|
|
@@ -434,4 +402,3 @@ const PlaylistEdit = ( {
|
|
|
434
402
|
};
|
|
435
403
|
|
|
436
404
|
export default PlaylistEdit;
|
|
437
|
-
export { getTrackAttributes };
|
package/src/playlist/style.scss
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
$waveform-player-height: 100px;
|
|
5
5
|
|
|
6
6
|
.wp-block-playlist {
|
|
7
|
+
// Clip content to respect border-radius.
|
|
8
|
+
// `overflow: hidden` is a fallback for browsers that don't support `overflow: clip`.
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
overflow: clip;
|
|
11
|
+
|
|
7
12
|
// Main waveform player container.
|
|
8
13
|
.wp-block-playlist__waveform-player {
|
|
9
14
|
width: 100%;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { v4 as uuid } from 'uuid';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Transform media library data into track block attributes.
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} media - Media object from the media library.
|
|
15
|
+
* @return {Object} Track attributes for the playlist-track block.
|
|
16
|
+
*/
|
|
17
|
+
export function getTrackAttributes( media ) {
|
|
18
|
+
return {
|
|
19
|
+
id: media.id || media.url, // Attachment ID or URL.
|
|
20
|
+
uniqueId: uuid(), // Unique ID for the track.
|
|
21
|
+
src: media.url,
|
|
22
|
+
title: media.title,
|
|
23
|
+
artist:
|
|
24
|
+
media.artist ||
|
|
25
|
+
media?.meta?.artist ||
|
|
26
|
+
media?.media_details?.artist ||
|
|
27
|
+
__( 'Unknown artist' ),
|
|
28
|
+
album:
|
|
29
|
+
media.album ||
|
|
30
|
+
media?.meta?.album ||
|
|
31
|
+
media?.media_details?.album ||
|
|
32
|
+
__( 'Unknown album' ),
|
|
33
|
+
length: media?.fileLength || media?.media_details?.length_formatted,
|
|
34
|
+
// Prevent using the default media attachment icon as the track image.
|
|
35
|
+
// Note: Image is not available when a new track is uploaded.
|
|
36
|
+
image:
|
|
37
|
+
media?.image?.src &&
|
|
38
|
+
media?.image?.src.endsWith( '/images/media/audio.svg' )
|
|
39
|
+
? ''
|
|
40
|
+
: media?.image?.src,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -7,9 +7,6 @@
|
|
|
7
7
|
"description": "Display the excerpt.",
|
|
8
8
|
"textdomain": "default",
|
|
9
9
|
"attributes": {
|
|
10
|
-
"textAlign": {
|
|
11
|
-
"type": "string"
|
|
12
|
-
},
|
|
13
10
|
"moreText": {
|
|
14
11
|
"type": "string",
|
|
15
12
|
"role": "content"
|
|
@@ -46,6 +43,7 @@
|
|
|
46
43
|
"typography": {
|
|
47
44
|
"fontSize": true,
|
|
48
45
|
"lineHeight": true,
|
|
46
|
+
"textAlign": true,
|
|
49
47
|
"textColumns": true,
|
|
50
48
|
"__experimentalFontFamily": true,
|
|
51
49
|
"__experimentalFontWeight": true,
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import migrateTextAlign from '../utils/migrate-text-align';
|
|
5
|
+
|
|
6
|
+
const v1 = {
|
|
7
|
+
attributes: {
|
|
8
|
+
textAlign: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
},
|
|
11
|
+
moreText: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
role: 'content',
|
|
14
|
+
},
|
|
15
|
+
showMoreOnNewLine: {
|
|
16
|
+
type: 'boolean',
|
|
17
|
+
default: true,
|
|
18
|
+
},
|
|
19
|
+
excerptLength: {
|
|
20
|
+
type: 'number',
|
|
21
|
+
default: 55,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
supports: {
|
|
25
|
+
anchor: true,
|
|
26
|
+
html: false,
|
|
27
|
+
color: {
|
|
28
|
+
gradients: true,
|
|
29
|
+
link: true,
|
|
30
|
+
__experimentalDefaultControls: {
|
|
31
|
+
background: true,
|
|
32
|
+
text: true,
|
|
33
|
+
link: true,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
spacing: {
|
|
37
|
+
margin: true,
|
|
38
|
+
padding: true,
|
|
39
|
+
},
|
|
40
|
+
typography: {
|
|
41
|
+
fontSize: true,
|
|
42
|
+
lineHeight: true,
|
|
43
|
+
textColumns: true,
|
|
44
|
+
__experimentalFontFamily: true,
|
|
45
|
+
__experimentalFontWeight: true,
|
|
46
|
+
__experimentalFontStyle: true,
|
|
47
|
+
__experimentalTextTransform: true,
|
|
48
|
+
__experimentalTextDecoration: true,
|
|
49
|
+
__experimentalLetterSpacing: true,
|
|
50
|
+
__experimentalDefaultControls: {
|
|
51
|
+
fontSize: true,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
interactivity: {
|
|
55
|
+
clientNavigation: true,
|
|
56
|
+
},
|
|
57
|
+
__experimentalBorder: {
|
|
58
|
+
radius: true,
|
|
59
|
+
color: true,
|
|
60
|
+
width: true,
|
|
61
|
+
style: true,
|
|
62
|
+
__experimentalDefaultControls: {
|
|
63
|
+
radius: true,
|
|
64
|
+
color: true,
|
|
65
|
+
width: true,
|
|
66
|
+
style: true,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
save() {
|
|
71
|
+
return null;
|
|
72
|
+
},
|
|
73
|
+
migrate: migrateTextAlign,
|
|
74
|
+
isEligible( attributes ) {
|
|
75
|
+
return (
|
|
76
|
+
!! attributes.textAlign ||
|
|
77
|
+
!! attributes.className?.match(
|
|
78
|
+
/\bhas-text-align-(left|center|right)\b/
|
|
79
|
+
)
|
|
80
|
+
);
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export default [ v1 ];
|
package/src/post-excerpt/edit.js
CHANGED
|
@@ -9,13 +9,10 @@ import clsx from 'clsx';
|
|
|
9
9
|
import { useEntityProp, store as coreStore } from '@wordpress/core-data';
|
|
10
10
|
import { useMemo } from '@wordpress/element';
|
|
11
11
|
import {
|
|
12
|
-
AlignmentToolbar,
|
|
13
|
-
BlockControls,
|
|
14
12
|
InspectorControls,
|
|
15
13
|
RichText,
|
|
16
14
|
Warning,
|
|
17
15
|
useBlockProps,
|
|
18
|
-
useBlockEditingMode,
|
|
19
16
|
} from '@wordpress/block-editor';
|
|
20
17
|
import {
|
|
21
18
|
ToggleControl,
|
|
@@ -33,17 +30,19 @@ import {
|
|
|
33
30
|
useCanEditEntity,
|
|
34
31
|
useToolsPanelDropdownMenuProps,
|
|
35
32
|
} from '../utils/hooks';
|
|
33
|
+
import useDeprecatedTextAlign from '../utils/deprecated-text-align-attributes';
|
|
36
34
|
|
|
37
35
|
const ELLIPSIS = '…';
|
|
38
36
|
|
|
39
|
-
export default function PostExcerptEditor( {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
export default function PostExcerptEditor( props ) {
|
|
38
|
+
const {
|
|
39
|
+
attributes: { moreText, showMoreOnNewLine, excerptLength },
|
|
40
|
+
setAttributes,
|
|
41
|
+
isSelected,
|
|
42
|
+
context: { postId, postType, queryId },
|
|
43
|
+
} = props;
|
|
44
|
+
useDeprecatedTextAlign( props );
|
|
45
|
+
|
|
47
46
|
const isDescendentOfQueryLoop = Number.isFinite( queryId );
|
|
48
47
|
const userCanEdit = useCanEditEntity( 'postType', postType, postId );
|
|
49
48
|
const [
|
|
@@ -83,11 +82,7 @@ export default function PostExcerptEditor( {
|
|
|
83
82
|
const isEditable =
|
|
84
83
|
userCanEdit && ! isDescendentOfQueryLoop && postTypeSupportsExcerpts;
|
|
85
84
|
|
|
86
|
-
const blockProps = useBlockProps(
|
|
87
|
-
className: clsx( {
|
|
88
|
-
[ `has-text-align-${ textAlign }` ]: textAlign,
|
|
89
|
-
} ),
|
|
90
|
-
} );
|
|
85
|
+
const blockProps = useBlockProps();
|
|
91
86
|
|
|
92
87
|
/**
|
|
93
88
|
* translators: If your word count is based on single characters (e.g. East Asian characters),
|
|
@@ -114,19 +109,9 @@ export default function PostExcerptEditor( {
|
|
|
114
109
|
|
|
115
110
|
if ( ! postType || ! postId ) {
|
|
116
111
|
return (
|
|
117
|
-
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
value={ textAlign }
|
|
121
|
-
onChange={ ( newAlign ) =>
|
|
122
|
-
setAttributes( { textAlign: newAlign } )
|
|
123
|
-
}
|
|
124
|
-
/>
|
|
125
|
-
</BlockControls>
|
|
126
|
-
<div { ...blockProps }>
|
|
127
|
-
<p>{ __( 'This block will display the excerpt.' ) }</p>
|
|
128
|
-
</div>
|
|
129
|
-
</>
|
|
112
|
+
<div { ...blockProps }>
|
|
113
|
+
<p>{ __( 'This block will display the excerpt.' ) }</p>
|
|
114
|
+
</div>
|
|
130
115
|
);
|
|
131
116
|
}
|
|
132
117
|
if ( isProtected && ! userCanEdit ) {
|
|
@@ -225,16 +210,6 @@ export default function PostExcerptEditor( {
|
|
|
225
210
|
);
|
|
226
211
|
return (
|
|
227
212
|
<>
|
|
228
|
-
{ showControls && (
|
|
229
|
-
<BlockControls>
|
|
230
|
-
<AlignmentToolbar
|
|
231
|
-
value={ textAlign }
|
|
232
|
-
onChange={ ( newAlign ) =>
|
|
233
|
-
setAttributes( { textAlign: newAlign } )
|
|
234
|
-
}
|
|
235
|
-
/>
|
|
236
|
-
</BlockControls>
|
|
237
|
-
) }
|
|
238
213
|
<InspectorControls>
|
|
239
214
|
<ToolsPanel
|
|
240
215
|
label={ __( 'Settings' ) }
|
|
@@ -10,6 +10,7 @@ import initBlock from '../utils/init-block';
|
|
|
10
10
|
import metadata from './block.json';
|
|
11
11
|
import edit from './edit';
|
|
12
12
|
import transforms from './transforms';
|
|
13
|
+
import deprecated from './deprecated';
|
|
13
14
|
|
|
14
15
|
const { name } = metadata;
|
|
15
16
|
export { metadata, name };
|
|
@@ -18,6 +19,7 @@ export const settings = {
|
|
|
18
19
|
icon,
|
|
19
20
|
transforms,
|
|
20
21
|
edit,
|
|
22
|
+
deprecated,
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
export const init = () => initBlock( { name, metadata, settings } );
|
package/src/private-apis.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { default as BlockKeyboardShortcuts } from './block-keyboard-shortcuts';
|
|
5
5
|
import { NAVIGATION_OVERLAY_TEMPLATE_PART_AREA } from './navigation/constants';
|
|
6
|
+
import { NavigationLinkUI } from './navigation/edit/navigation-link-ui';
|
|
6
7
|
import { lock } from './lock-unlock';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -12,4 +13,5 @@ export const privateApis = {};
|
|
|
12
13
|
lock( privateApis, {
|
|
13
14
|
BlockKeyboardShortcuts,
|
|
14
15
|
NAVIGATION_OVERLAY_TEMPLATE_PART_AREA,
|
|
16
|
+
NavigationLinkUI,
|
|
15
17
|
} );
|
package/src/shortcode/block.json
CHANGED
|
@@ -128,11 +128,13 @@ export default function TemplatePartEdit( {
|
|
|
128
128
|
onNavigateToEntityRecord,
|
|
129
129
|
title,
|
|
130
130
|
canUserEdit,
|
|
131
|
+
canUserEditBlock,
|
|
131
132
|
} = useSelect(
|
|
132
133
|
( select ) => {
|
|
133
134
|
const { getEditedEntityRecord, hasFinishedResolution } =
|
|
134
135
|
select( coreStore );
|
|
135
|
-
const { getBlockCount, getSettings } =
|
|
136
|
+
const { getBlockCount, getSettings, canEditBlock } =
|
|
137
|
+
select( blockEditorStore );
|
|
136
138
|
|
|
137
139
|
const getEntityArgs = [
|
|
138
140
|
'postType',
|
|
@@ -170,6 +172,7 @@ export default function TemplatePartEdit( {
|
|
|
170
172
|
getSettings().onNavigateToEntityRecord,
|
|
171
173
|
title: entityRecord?.title,
|
|
172
174
|
canUserEdit: !! _canUserEdit,
|
|
175
|
+
canUserEditBlock: canEditBlock( clientId ),
|
|
173
176
|
};
|
|
174
177
|
},
|
|
175
178
|
[ templatePartId, attributes.area, clientId ]
|
|
@@ -284,6 +287,7 @@ export default function TemplatePartEdit( {
|
|
|
284
287
|
// Only enable for single selection that matches the current block.
|
|
285
288
|
// Ensures menu item doesn't render multiple times.
|
|
286
289
|
if (
|
|
290
|
+
! canUserEditBlock ||
|
|
287
291
|
! (
|
|
288
292
|
selectedClientIds.length === 1 &&
|
|
289
293
|
clientId === selectedClientIds[ 0 ]
|