@wordpress/block-library 9.6.0 → 9.7.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/audio/edit.js +2 -1
- package/build/audio/edit.js.map +1 -1
- package/build/block/edit.js +3 -5
- package/build/block/edit.js.map +1 -1
- package/build/button/edit.js +1 -1
- package/build/button/edit.js.map +1 -1
- package/build/categories/index.js +1 -0
- package/build/categories/index.js.map +1 -1
- package/build/comment-edit-link/index.js +13 -2
- package/build/comment-edit-link/index.js.map +1 -1
- package/build/comment-reply-link/index.js +13 -2
- package/build/comment-reply-link/index.js.map +1 -1
- package/build/comments/edit/comments-legacy.js +4 -1
- package/build/comments/edit/comments-legacy.js.map +1 -1
- package/build/cover/edit/block-controls.js +4 -2
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/cover/edit/index.js +2 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +4 -12
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/details/index.js +3 -1
- package/build/details/index.js.map +1 -1
- package/build/details/transforms.js +24 -0
- package/build/details/transforms.js.map +1 -0
- package/build/embed/embed-placeholder.js +8 -2
- package/build/embed/embed-placeholder.js.map +1 -1
- package/build/file/edit.js +12 -1
- package/build/file/edit.js.map +1 -1
- package/build/freeform/edit.js +4 -4
- package/build/freeform/edit.js.map +1 -1
- package/build/freeform/modal.js +12 -3
- package/build/freeform/modal.js.map +1 -1
- package/build/home-link/edit.js +3 -9
- package/build/home-link/edit.js.map +1 -1
- package/build/image/edit.js +44 -34
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +22 -10
- package/build/image/image.js.map +1 -1
- package/build/media-text/deprecated.js +144 -3
- package/build/media-text/deprecated.js.map +1 -1
- package/build/media-text/edit.js +5 -5
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/image-fill.js +12 -0
- package/build/media-text/image-fill.js.map +1 -0
- package/build/media-text/media-container.js +21 -18
- package/build/media-text/media-container.js.map +1 -1
- package/build/media-text/media-container.native.js +0 -7
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/media-text/save.js +5 -6
- package/build/media-text/save.js.map +1 -1
- package/build/missing/edit.js +6 -3
- package/build/missing/edit.js.map +1 -1
- package/build/navigation/edit/deleted-navigation-warning.js +4 -1
- package/build/navigation/edit/deleted-navigation-warning.js.map +1 -1
- package/build/navigation/edit/index.js +4 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-delete-control.js +4 -1
- package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +4 -1
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +8 -2
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +4 -4
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation-link/link-ui.js +5 -2
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +8 -2
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/edit.js +7 -2
- package/build/page-list/edit.js.map +1 -1
- package/build/post-comments-form/form.js +4 -1
- package/build/post-comments-form/form.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +6 -8
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-featured-image/edit.js +5 -5
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/query/edit/enhanced-pagination-modal.js +4 -1
- package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build/query/edit/query-placeholder.js +8 -2
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/site-logo/edit.js +15 -15
- package/build/site-logo/edit.js.map +1 -1
- package/build/social-link/edit.js +4 -1
- package/build/social-link/edit.js.map +1 -1
- package/build/social-links/edit.js +10 -9
- package/build/social-links/edit.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/index.js +1 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/placeholder.js +8 -2
- package/build/template-part/edit/placeholder.js.map +1 -1
- package/build/utils/hooks.js +10 -10
- package/build/utils/hooks.js.map +1 -1
- package/build/video/edit.js +22 -14
- package/build/video/edit.js.map +1 -1
- package/build/video/tracks-editor.js +12 -3
- package/build/video/tracks-editor.js.map +1 -1
- package/build-module/audio/edit.js +2 -1
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/block/edit.js +4 -6
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/edit.js +1 -1
- package/build-module/button/edit.js.map +1 -1
- package/build-module/categories/index.js +1 -0
- package/build-module/categories/index.js.map +1 -1
- package/build-module/comment-edit-link/index.js +13 -2
- package/build-module/comment-edit-link/index.js.map +1 -1
- package/build-module/comment-reply-link/index.js +13 -2
- package/build-module/comment-reply-link/index.js.map +1 -1
- package/build-module/comments/edit/comments-legacy.js +4 -1
- package/build-module/comments/edit/comments-legacy.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +4 -2
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/cover/edit/index.js +2 -1
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +5 -13
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/details/index.js +3 -1
- package/build-module/details/index.js.map +1 -1
- package/build-module/details/transforms.js +18 -0
- package/build-module/details/transforms.js.map +1 -0
- package/build-module/embed/embed-placeholder.js +8 -2
- package/build-module/embed/embed-placeholder.js.map +1 -1
- package/build-module/file/edit.js +12 -1
- package/build-module/file/edit.js.map +1 -1
- package/build-module/freeform/edit.js +4 -4
- package/build-module/freeform/edit.js.map +1 -1
- package/build-module/freeform/modal.js +12 -3
- package/build-module/freeform/modal.js.map +1 -1
- package/build-module/home-link/edit.js +3 -9
- package/build-module/home-link/edit.js.map +1 -1
- package/build-module/image/edit.js +45 -34
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +23 -11
- package/build-module/image/image.js.map +1 -1
- package/build-module/media-text/deprecated.js +144 -3
- package/build-module/media-text/deprecated.js.map +1 -1
- package/build-module/media-text/edit.js +5 -5
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/image-fill.js +6 -0
- package/build-module/media-text/image-fill.js.map +1 -0
- package/build-module/media-text/media-container.js +21 -17
- package/build-module/media-text/media-container.js.map +1 -1
- package/build-module/media-text/media-container.native.js +0 -1
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/media-text/save.js +5 -6
- package/build-module/media-text/save.js.map +1 -1
- package/build-module/missing/edit.js +6 -3
- package/build-module/missing/edit.js.map +1 -1
- package/build-module/navigation/edit/deleted-navigation-warning.js +4 -1
- package/build-module/navigation/edit/deleted-navigation-warning.js.map +1 -1
- package/build-module/navigation/edit/index.js +4 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-delete-control.js +4 -1
- package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +4 -1
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +8 -2
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +4 -4
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +7 -4
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +8 -2
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/edit.js +7 -2
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +4 -1
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +6 -8
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-featured-image/edit.js +6 -6
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/query/edit/enhanced-pagination-modal.js +4 -1
- package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +8 -2
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/site-logo/edit.js +16 -16
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/social-link/edit.js +4 -1
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-links/edit.js +11 -10
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +1 -1
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/placeholder.js +8 -2
- package/build-module/template-part/edit/placeholder.js.map +1 -1
- package/build-module/utils/hooks.js +10 -10
- package/build-module/utils/hooks.js.map +1 -1
- package/build-module/video/edit.js +22 -15
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/tracks-editor.js +12 -3
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/button/editor-rtl.css +0 -4
- package/build-style/button/editor.css +0 -4
- package/build-style/buttons/editor-rtl.css +0 -3
- package/build-style/buttons/editor.css +0 -3
- package/build-style/comment-edit-link/style-rtl.css +94 -0
- package/build-style/comment-edit-link/style.css +94 -0
- package/build-style/comment-reply-link/style-rtl.css +94 -0
- package/build-style/comment-reply-link/style.css +94 -0
- package/build-style/comments-pagination/editor-rtl.css +2 -2
- package/build-style/comments-pagination/editor.css +2 -2
- package/build-style/cover/editor-rtl.css +0 -6
- package/build-style/cover/editor.css +0 -6
- package/build-style/editor-rtl.css +24 -68
- package/build-style/editor.css +24 -70
- package/build-style/group/editor-rtl.css +0 -1
- package/build-style/group/editor.css +0 -1
- package/build-style/image/editor-rtl.css +0 -1
- package/build-style/image/editor.css +0 -1
- package/build-style/media-text/editor-rtl.css +3 -1
- package/build-style/media-text/editor.css +3 -1
- package/build-style/media-text/style-rtl.css +20 -0
- package/build-style/media-text/style.css +20 -0
- package/build-style/navigation/editor-rtl.css +0 -1
- package/build-style/navigation/editor.css +0 -1
- package/build-style/post-featured-image/style-rtl.css +1 -1
- package/build-style/post-featured-image/style.css +1 -1
- package/build-style/query-pagination/editor-rtl.css +2 -16
- package/build-style/query-pagination/editor.css +2 -18
- package/build-style/query-pagination/style-rtl.css +0 -11
- package/build-style/query-pagination/style.css +0 -13
- package/build-style/site-title/editor-rtl.css +0 -4
- package/build-style/site-title/editor.css +0 -4
- package/build-style/social-links/editor-rtl.css +17 -0
- package/build-style/social-links/editor.css +17 -0
- package/build-style/style-rtl.css +29 -12
- package/build-style/style.css +29 -14
- package/build-style/video/editor-rtl.css +0 -29
- package/build-style/video/editor.css +0 -29
- package/package.json +35 -35
- package/src/audio/edit.js +1 -0
- package/src/block/edit.js +6 -4
- package/src/button/edit.js +1 -1
- package/src/button/editor.scss +0 -5
- package/src/buttons/editor.scss +0 -6
- package/src/categories/block.json +1 -0
- package/src/categories/index.php +13 -2
- package/src/comment-date/index.php +1 -1
- package/src/comment-edit-link/block.json +13 -2
- package/src/comment-edit-link/style.scss +4 -0
- package/src/comment-reply-link/block.json +13 -2
- package/src/comment-reply-link/style.scss +4 -0
- package/src/comments/edit/comments-legacy.js +2 -0
- package/src/comments-pagination/editor.scss +1 -1
- package/src/cover/edit/block-controls.js +2 -0
- package/src/cover/edit/index.js +1 -0
- package/src/cover/edit/inspector-controls.js +3 -15
- package/src/cover/editor.scss +0 -5
- package/src/cover/test/edit.js +30 -26
- package/src/details/index.js +2 -0
- package/src/details/transforms.js +26 -0
- package/src/embed/embed-placeholder.js +12 -2
- package/src/file/edit.js +11 -0
- package/src/form/index.php +2 -2
- package/src/freeform/edit.js +4 -4
- package/src/freeform/editor.scss +1 -1
- package/src/freeform/modal.js +10 -1
- package/src/gallery/editor.scss +1 -1
- package/src/group/editor.scss +0 -1
- package/src/home-link/edit.js +4 -7
- package/src/image/edit.js +42 -30
- package/src/image/editor.scss +0 -3
- package/src/image/image.js +75 -53
- package/src/media-text/deprecated.js +159 -3
- package/src/media-text/edit.js +5 -5
- package/src/media-text/editor.scss +3 -1
- package/src/media-text/image-fill.js +11 -0
- package/src/media-text/index.php +53 -43
- package/src/media-text/media-container.js +25 -25
- package/src/media-text/media-container.native.js +0 -2
- package/src/media-text/save.js +9 -13
- package/src/media-text/style.scss +21 -0
- package/src/media-text/test/image-fill.js +19 -0
- package/src/missing/edit.js +9 -3
- package/src/navigation/edit/deleted-navigation-warning.js +8 -1
- package/src/navigation/edit/index.js +2 -0
- package/src/navigation/edit/navigation-menu-delete-control.js +2 -0
- package/src/navigation/edit/placeholder/index.js +2 -0
- package/src/navigation/edit/responsive-wrapper.js +4 -0
- package/src/navigation/edit/unsaved-inner-blocks.js +4 -4
- package/src/navigation/editor.scss +6 -3
- package/src/navigation-link/link-ui.js +5 -3
- package/src/page-list/convert-to-links-modal.js +8 -1
- package/src/page-list/edit.js +7 -1
- package/src/page-list/index.php +3 -1
- package/src/post-comments-form/form.js +2 -0
- package/src/post-date/index.php +3 -3
- package/src/post-featured-image/dimension-controls.js +4 -4
- package/src/post-featured-image/edit.js +4 -6
- package/src/post-featured-image/style.scss +1 -1
- package/src/query/edit/enhanced-pagination-modal.js +6 -1
- package/src/query/edit/query-placeholder.js +4 -0
- package/src/query-pagination/editor.scss +1 -21
- package/src/query-pagination/style.scss +0 -15
- package/src/site-logo/edit.js +13 -20
- package/src/site-title/editor.scss +0 -4
- package/src/social-link/edit.js +2 -0
- package/src/social-links/edit.js +17 -10
- package/src/social-links/editor.scss +24 -5
- package/src/style.scss +2 -0
- package/src/tag-cloud/index.php +7 -2
- package/src/template-part/edit/advanced-controls.js +0 -1
- package/src/template-part/edit/index.js +12 -10
- package/src/template-part/edit/placeholder.js +8 -1
- package/src/utils/hooks.js +11 -11
- package/src/video/edit.js +26 -21
- package/src/video/editor.scss +0 -45
- package/src/video/tracks-editor.js +6 -0
- package/src/media-text/test/media-container.js +0 -24
package/src/form/index.php
CHANGED
|
@@ -92,7 +92,7 @@ function block_core_form_send_email() {
|
|
|
92
92
|
// Start building the email content.
|
|
93
93
|
$content = sprintf(
|
|
94
94
|
/* translators: %s: The request URI. */
|
|
95
|
-
__( 'Form submission from %1$s'
|
|
95
|
+
__( 'Form submission from %1$s' ) . '</br>',
|
|
96
96
|
'<a href="' . esc_url( get_site_url( null, $params['_wp_http_referer'] ) ) . '">' . get_bloginfo( 'name' ) . '</a>'
|
|
97
97
|
);
|
|
98
98
|
|
|
@@ -110,7 +110,7 @@ function block_core_form_send_email() {
|
|
|
110
110
|
// Send the email.
|
|
111
111
|
$result = wp_mail(
|
|
112
112
|
str_replace( 'mailto:', '', $params['formAction'] ),
|
|
113
|
-
__( 'Form submission'
|
|
113
|
+
__( 'Form submission' ),
|
|
114
114
|
$content
|
|
115
115
|
);
|
|
116
116
|
|
package/src/freeform/edit.js
CHANGED
|
@@ -75,10 +75,10 @@ function ClassicEdit( {
|
|
|
75
75
|
onReplace,
|
|
76
76
|
} ) {
|
|
77
77
|
const { getMultiSelectedBlockClientIds } = useSelect( blockEditorStore );
|
|
78
|
-
const
|
|
78
|
+
const didMountRef = useRef( false );
|
|
79
79
|
|
|
80
80
|
useEffect( () => {
|
|
81
|
-
if ( !
|
|
81
|
+
if ( ! didMountRef.current ) {
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -96,7 +96,7 @@ function ClassicEdit( {
|
|
|
96
96
|
useEffect( () => {
|
|
97
97
|
const { baseURL, suffix } = window.wpEditorL10n.tinymce;
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
didMountRef.current = true;
|
|
100
100
|
|
|
101
101
|
window.tinymce.EditorManager.overrideDefaults( {
|
|
102
102
|
base_url: baseURL,
|
|
@@ -230,7 +230,7 @@ function ClassicEdit( {
|
|
|
230
230
|
onReadyStateChange
|
|
231
231
|
);
|
|
232
232
|
wp.oldEditor.remove( `editor-${ clientId }` );
|
|
233
|
-
|
|
233
|
+
didMountRef.current = false;
|
|
234
234
|
};
|
|
235
235
|
}, [] );
|
|
236
236
|
|
package/src/freeform/editor.scss
CHANGED
|
@@ -299,7 +299,7 @@ div[data-type="core/freeform"] {
|
|
|
299
299
|
top: 0;
|
|
300
300
|
border: $border-width solid $gray-300;
|
|
301
301
|
border-bottom: none;
|
|
302
|
-
border-radius: $radius-
|
|
302
|
+
border-radius: $radius-small;
|
|
303
303
|
margin-bottom: $grid-unit-10;
|
|
304
304
|
|
|
305
305
|
// On mobile, toolbars go edge to edge.
|
package/src/freeform/modal.js
CHANGED
|
@@ -25,6 +25,8 @@ function ModalAuxiliaryActions( { onClick, isModalFullScreen } ) {
|
|
|
25
25
|
|
|
26
26
|
return (
|
|
27
27
|
<Button
|
|
28
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
29
|
+
__next40pxDefaultSize={ false }
|
|
28
30
|
onClick={ onClick }
|
|
29
31
|
icon={ fullscreen }
|
|
30
32
|
isPressed={ isModalFullScreen }
|
|
@@ -120,12 +122,19 @@ export default function ModalEdit( props ) {
|
|
|
120
122
|
expanded={ false }
|
|
121
123
|
>
|
|
122
124
|
<FlexItem>
|
|
123
|
-
<Button
|
|
125
|
+
<Button
|
|
126
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
127
|
+
__next40pxDefaultSize={ false }
|
|
128
|
+
variant="tertiary"
|
|
129
|
+
onClick={ onClose }
|
|
130
|
+
>
|
|
124
131
|
{ __( 'Cancel' ) }
|
|
125
132
|
</Button>
|
|
126
133
|
</FlexItem>
|
|
127
134
|
<FlexItem>
|
|
128
135
|
<Button
|
|
136
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
137
|
+
__next40pxDefaultSize={ false }
|
|
129
138
|
variant="primary"
|
|
130
139
|
onClick={ () => {
|
|
131
140
|
setAttributes( {
|
package/src/gallery/editor.scss
CHANGED
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
z-index: z-index(".block-library-gallery-item__inline-menu");
|
|
140
140
|
transition: box-shadow 0.2s ease-out;
|
|
141
141
|
@include reduce-motion("transition");
|
|
142
|
-
border-radius: $radius-
|
|
142
|
+
border-radius: $radius-small;
|
|
143
143
|
background: $white;
|
|
144
144
|
border: $border-width solid $gray-900;
|
|
145
145
|
|
package/src/group/editor.scss
CHANGED
package/src/home-link/edit.js
CHANGED
|
@@ -19,13 +19,10 @@ import { useEffect } from '@wordpress/element';
|
|
|
19
19
|
const preventDefault = ( event ) => event.preventDefault();
|
|
20
20
|
|
|
21
21
|
export default function HomeEdit( { attributes, setAttributes, context } ) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
homeUrl: getUnstableBase()?.home,
|
|
28
|
-
};
|
|
22
|
+
const homeUrl = useSelect( ( select ) => {
|
|
23
|
+
// Site index.
|
|
24
|
+
return select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
|
|
25
|
+
?.home;
|
|
29
26
|
}, [] );
|
|
30
27
|
const { __unstableMarkNextChangeAsNotPersistent } =
|
|
31
28
|
useDispatch( blockEditorStore );
|
package/src/image/edit.js
CHANGED
|
@@ -23,6 +23,7 @@ import { useEffect, useRef, useState } from '@wordpress/element';
|
|
|
23
23
|
import { __, sprintf } from '@wordpress/i18n';
|
|
24
24
|
import { image as icon, plugins as pluginsIcon } from '@wordpress/icons';
|
|
25
25
|
import { store as noticesStore } from '@wordpress/notices';
|
|
26
|
+
import { useResizeObserver } from '@wordpress/compose';
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Internal dependencies
|
|
@@ -109,6 +110,9 @@ export function ImageEdit( {
|
|
|
109
110
|
} = attributes;
|
|
110
111
|
const [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );
|
|
111
112
|
|
|
113
|
+
const [ contentResizeListener, { width: containerWidth } ] =
|
|
114
|
+
useResizeObserver();
|
|
115
|
+
|
|
112
116
|
const altRef = useRef();
|
|
113
117
|
useEffect( () => {
|
|
114
118
|
altRef.current = alt;
|
|
@@ -322,7 +326,7 @@ export function ImageEdit( {
|
|
|
322
326
|
: __( 'Connected to dynamic data' ),
|
|
323
327
|
};
|
|
324
328
|
},
|
|
325
|
-
[ isSingleSelected, metadata?.bindings?.url ]
|
|
329
|
+
[ context, isSingleSelected, metadata?.bindings?.url ]
|
|
326
330
|
);
|
|
327
331
|
const placeholder = ( content ) => {
|
|
328
332
|
return (
|
|
@@ -364,35 +368,43 @@ export function ImageEdit( {
|
|
|
364
368
|
};
|
|
365
369
|
|
|
366
370
|
return (
|
|
367
|
-
|
|
368
|
-
<
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
371
|
+
<>
|
|
372
|
+
<figure { ...blockProps }>
|
|
373
|
+
<Image
|
|
374
|
+
temporaryURL={ temporaryURL }
|
|
375
|
+
attributes={ attributes }
|
|
376
|
+
setAttributes={ setAttributes }
|
|
377
|
+
isSingleSelected={ isSingleSelected }
|
|
378
|
+
insertBlocksAfter={ insertBlocksAfter }
|
|
379
|
+
onReplace={ onReplace }
|
|
380
|
+
onSelectImage={ onSelectImage }
|
|
381
|
+
onSelectURL={ onSelectURL }
|
|
382
|
+
onUploadError={ onUploadError }
|
|
383
|
+
context={ context }
|
|
384
|
+
clientId={ clientId }
|
|
385
|
+
blockEditingMode={ blockEditingMode }
|
|
386
|
+
parentLayoutType={ parentLayout?.type }
|
|
387
|
+
containerWidth={ containerWidth }
|
|
388
|
+
/>
|
|
389
|
+
<MediaPlaceholder
|
|
390
|
+
icon={ <BlockIcon icon={ icon } /> }
|
|
391
|
+
onSelect={ onSelectImage }
|
|
392
|
+
onSelectURL={ onSelectURL }
|
|
393
|
+
onError={ onUploadError }
|
|
394
|
+
placeholder={ placeholder }
|
|
395
|
+
accept="image/*"
|
|
396
|
+
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
397
|
+
value={ { id, src } }
|
|
398
|
+
mediaPreview={ mediaPreview }
|
|
399
|
+
disableMediaButtons={ temporaryURL || url }
|
|
400
|
+
/>
|
|
401
|
+
</figure>
|
|
402
|
+
{
|
|
403
|
+
// The listener cannot be placed as the first element as it will break the in-between inserter.
|
|
404
|
+
// See https://github.com/WordPress/gutenberg/blob/71134165868298fc15e22896d0c28b41b3755ff7/packages/block-editor/src/components/block-list/use-in-between-inserter.js#L120
|
|
405
|
+
contentResizeListener
|
|
406
|
+
}
|
|
407
|
+
</>
|
|
396
408
|
);
|
|
397
409
|
}
|
|
398
410
|
|
package/src/image/editor.scss
CHANGED
|
@@ -13,9 +13,6 @@
|
|
|
13
13
|
// Disable any duotone filter applied in the selected state.
|
|
14
14
|
filter: none !important;
|
|
15
15
|
|
|
16
|
-
// @todo this should eventually be overridden by a custom border-radius set in the inspector.
|
|
17
|
-
border-radius: $radius-block-ui;
|
|
18
|
-
|
|
19
16
|
> svg {
|
|
20
17
|
opacity: 0;
|
|
21
18
|
}
|
package/src/image/image.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { isBlobURL } from '@wordpress/blob';
|
|
5
5
|
import {
|
|
6
|
-
MenuItem,
|
|
7
6
|
ExternalLink,
|
|
8
7
|
ResizableBox,
|
|
9
8
|
Spinner,
|
|
@@ -109,6 +108,7 @@ export default function Image( {
|
|
|
109
108
|
clientId,
|
|
110
109
|
blockEditingMode,
|
|
111
110
|
parentLayoutType,
|
|
111
|
+
containerWidth,
|
|
112
112
|
} ) {
|
|
113
113
|
const {
|
|
114
114
|
url = '',
|
|
@@ -357,7 +357,11 @@ export default function Image( {
|
|
|
357
357
|
}, [ isSingleSelected ] );
|
|
358
358
|
|
|
359
359
|
const canEditImage = id && naturalWidth && naturalHeight && imageEditing;
|
|
360
|
-
const allowCrop =
|
|
360
|
+
const allowCrop =
|
|
361
|
+
isSingleSelected &&
|
|
362
|
+
canEditImage &&
|
|
363
|
+
! isEditingImage &&
|
|
364
|
+
! isContentOnlyMode;
|
|
361
365
|
|
|
362
366
|
function switchToCover() {
|
|
363
367
|
replaceBlocks(
|
|
@@ -598,11 +602,8 @@ export default function Image( {
|
|
|
598
602
|
onSelect={ onSelectImage }
|
|
599
603
|
onSelectURL={ onSelectURL }
|
|
600
604
|
onError={ onUploadError }
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
{ __( 'Reset' ) }
|
|
604
|
-
</MenuItem>
|
|
605
|
-
</MediaReplaceFlow>
|
|
605
|
+
onReset={ () => onSelectImage( undefined ) }
|
|
606
|
+
/>
|
|
606
607
|
</BlockControls>
|
|
607
608
|
) }
|
|
608
609
|
{ isSingleSelected && externalBlob && (
|
|
@@ -636,7 +637,7 @@ export default function Image( {
|
|
|
636
637
|
} }
|
|
637
638
|
>
|
|
638
639
|
{ _x(
|
|
639
|
-
'
|
|
640
|
+
'Alternative text',
|
|
640
641
|
'Alternative text for an image. Block toolbar label, a low character count is preferred.'
|
|
641
642
|
) }
|
|
642
643
|
</ToolbarButton>
|
|
@@ -676,51 +677,56 @@ export default function Image( {
|
|
|
676
677
|
/>
|
|
677
678
|
) }
|
|
678
679
|
/>
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
680
|
+
{ title && (
|
|
681
|
+
<Dropdown
|
|
682
|
+
popoverProps={ { position: 'bottom right' } }
|
|
683
|
+
renderToggle={ ( { isOpen, onToggle } ) => (
|
|
684
|
+
<ToolbarButton
|
|
685
|
+
onClick={ onToggle }
|
|
686
|
+
aria-haspopup="true"
|
|
687
|
+
aria-expanded={ isOpen }
|
|
688
|
+
onKeyDown={ ( event ) => {
|
|
689
|
+
if (
|
|
690
|
+
! isOpen &&
|
|
691
|
+
event.keyCode === DOWN
|
|
692
|
+
) {
|
|
693
|
+
event.preventDefault();
|
|
694
|
+
onToggle();
|
|
695
|
+
}
|
|
696
|
+
} }
|
|
697
|
+
>
|
|
698
|
+
{ __( 'Title' ) }
|
|
699
|
+
</ToolbarButton>
|
|
700
|
+
) }
|
|
701
|
+
renderContent={ () => (
|
|
702
|
+
<TextControl
|
|
703
|
+
__next40pxDefaultSize
|
|
704
|
+
className="wp-block-image__toolbar_content_textarea"
|
|
705
|
+
__nextHasNoMarginBottom
|
|
706
|
+
label={ __( 'Title attribute' ) }
|
|
707
|
+
value={ title || '' }
|
|
708
|
+
onChange={ onSetTitle }
|
|
709
|
+
disabled={ lockTitleControls }
|
|
710
|
+
help={
|
|
711
|
+
lockTitleControls ? (
|
|
712
|
+
<>{ lockTitleControlsMessage }</>
|
|
713
|
+
) : (
|
|
714
|
+
<>
|
|
714
715
|
{ __(
|
|
715
|
-
'
|
|
716
|
+
'Describe the role of this image on the page.'
|
|
716
717
|
) }
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
718
|
+
<ExternalLink href="https://www.w3.org/TR/html52/dom.html#the-title-attribute">
|
|
719
|
+
{ __(
|
|
720
|
+
'(Note: many devices and browsers do not display this text.)'
|
|
721
|
+
) }
|
|
722
|
+
</ExternalLink>
|
|
723
|
+
</>
|
|
724
|
+
)
|
|
725
|
+
}
|
|
726
|
+
/>
|
|
727
|
+
) }
|
|
728
|
+
/>
|
|
729
|
+
) }
|
|
724
730
|
</BlockControls>
|
|
725
731
|
) }
|
|
726
732
|
<InspectorControls>
|
|
@@ -928,6 +934,7 @@ export default function Image( {
|
|
|
928
934
|
// @todo It would be good to revisit this once a content-width variable
|
|
929
935
|
// becomes available.
|
|
930
936
|
const maxWidthBuffer = maxWidth * 2.5;
|
|
937
|
+
const maxContentWidth = containerWidth || maxWidthBuffer;
|
|
931
938
|
|
|
932
939
|
let showRightHandle = false;
|
|
933
940
|
let showLeftHandle = false;
|
|
@@ -973,9 +980,9 @@ export default function Image( {
|
|
|
973
980
|
} }
|
|
974
981
|
showHandle={ isSingleSelected }
|
|
975
982
|
minWidth={ minWidth }
|
|
976
|
-
maxWidth={
|
|
983
|
+
maxWidth={ maxContentWidth }
|
|
977
984
|
minHeight={ minHeight }
|
|
978
|
-
maxHeight={
|
|
985
|
+
maxHeight={ maxContentWidth / ratio }
|
|
979
986
|
lockAspectRatio={ ratio }
|
|
980
987
|
enable={ {
|
|
981
988
|
top: false,
|
|
@@ -986,6 +993,21 @@ export default function Image( {
|
|
|
986
993
|
onResizeStart={ onResizeStart }
|
|
987
994
|
onResizeStop={ ( event, direction, elt ) => {
|
|
988
995
|
onResizeStop();
|
|
996
|
+
|
|
997
|
+
// Clear hardcoded width if the resized width is close to the max-content width.
|
|
998
|
+
if (
|
|
999
|
+
// Only do this if the image is bigger than the container to prevent it from being squished.
|
|
1000
|
+
// TODO: Remove this check if the image support setting 100% width.
|
|
1001
|
+
naturalWidth >= maxContentWidth &&
|
|
1002
|
+
Math.abs( elt.offsetWidth - maxContentWidth ) < 10
|
|
1003
|
+
) {
|
|
1004
|
+
setAttributes( {
|
|
1005
|
+
width: undefined,
|
|
1006
|
+
height: undefined,
|
|
1007
|
+
} );
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
989
1011
|
// Since the aspect ratio is locked when resizing, we can
|
|
990
1012
|
// use the width of the resized element to calculate the
|
|
991
1013
|
// height in CSS to prevent stretching when the max-width
|
|
@@ -30,7 +30,7 @@ const v1ToV5ImageFillStyles = ( url, focalPoint ) => {
|
|
|
30
30
|
: {};
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
const
|
|
33
|
+
const v6ToV7ImageFillStyles = ( url, focalPoint ) => {
|
|
34
34
|
return url
|
|
35
35
|
? {
|
|
36
36
|
backgroundImage: `url(${ url })`,
|
|
@@ -198,6 +198,20 @@ const v6Attributes = {
|
|
|
198
198
|
},
|
|
199
199
|
};
|
|
200
200
|
|
|
201
|
+
const v7Attributes = {
|
|
202
|
+
...v6Attributes,
|
|
203
|
+
align: {
|
|
204
|
+
type: 'string',
|
|
205
|
+
// v7 changed the default for the `align` attribute.
|
|
206
|
+
default: 'none',
|
|
207
|
+
},
|
|
208
|
+
// New attribute.
|
|
209
|
+
useFeaturedImage: {
|
|
210
|
+
type: 'boolean',
|
|
211
|
+
default: false,
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
|
|
201
215
|
const v4ToV5Supports = {
|
|
202
216
|
anchor: true,
|
|
203
217
|
align: [ 'wide', 'full' ],
|
|
@@ -237,6 +251,148 @@ const v6Supports = {
|
|
|
237
251
|
},
|
|
238
252
|
};
|
|
239
253
|
|
|
254
|
+
const v7Supports = {
|
|
255
|
+
...v6Supports,
|
|
256
|
+
__experimentalBorder: {
|
|
257
|
+
color: true,
|
|
258
|
+
radius: true,
|
|
259
|
+
style: true,
|
|
260
|
+
width: true,
|
|
261
|
+
__experimentalDefaultControls: {
|
|
262
|
+
color: true,
|
|
263
|
+
radius: true,
|
|
264
|
+
style: true,
|
|
265
|
+
width: true,
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
color: {
|
|
269
|
+
gradients: true,
|
|
270
|
+
heading: true,
|
|
271
|
+
link: true,
|
|
272
|
+
__experimentalDefaultControls: {
|
|
273
|
+
background: true,
|
|
274
|
+
text: true,
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
interactivity: {
|
|
278
|
+
clientNavigation: true,
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
// Version with 'none' as the default alignment.
|
|
283
|
+
// See: https://github.com/WordPress/gutenberg/pull/64981
|
|
284
|
+
const v7 = {
|
|
285
|
+
attributes: v7Attributes,
|
|
286
|
+
supports: v7Supports,
|
|
287
|
+
usesContext: [ 'postId', 'postType' ],
|
|
288
|
+
save( { attributes } ) {
|
|
289
|
+
const {
|
|
290
|
+
isStackedOnMobile,
|
|
291
|
+
mediaAlt,
|
|
292
|
+
mediaPosition,
|
|
293
|
+
mediaType,
|
|
294
|
+
mediaUrl,
|
|
295
|
+
mediaWidth,
|
|
296
|
+
mediaId,
|
|
297
|
+
verticalAlignment,
|
|
298
|
+
imageFill,
|
|
299
|
+
focalPoint,
|
|
300
|
+
linkClass,
|
|
301
|
+
href,
|
|
302
|
+
linkTarget,
|
|
303
|
+
rel,
|
|
304
|
+
} = attributes;
|
|
305
|
+
const mediaSizeSlug =
|
|
306
|
+
attributes.mediaSizeSlug || DEFAULT_MEDIA_SIZE_SLUG;
|
|
307
|
+
const newRel = ! rel ? undefined : rel;
|
|
308
|
+
|
|
309
|
+
const imageClasses = clsx( {
|
|
310
|
+
[ `wp-image-${ mediaId }` ]: mediaId && mediaType === 'image',
|
|
311
|
+
[ `size-${ mediaSizeSlug }` ]: mediaId && mediaType === 'image',
|
|
312
|
+
} );
|
|
313
|
+
|
|
314
|
+
let image = mediaUrl ? (
|
|
315
|
+
<img
|
|
316
|
+
src={ mediaUrl }
|
|
317
|
+
alt={ mediaAlt }
|
|
318
|
+
className={ imageClasses || null }
|
|
319
|
+
/>
|
|
320
|
+
) : null;
|
|
321
|
+
|
|
322
|
+
if ( href ) {
|
|
323
|
+
image = (
|
|
324
|
+
<a
|
|
325
|
+
className={ linkClass }
|
|
326
|
+
href={ href }
|
|
327
|
+
target={ linkTarget }
|
|
328
|
+
rel={ newRel }
|
|
329
|
+
>
|
|
330
|
+
{ image }
|
|
331
|
+
</a>
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const mediaTypeRenders = {
|
|
336
|
+
image: () => image,
|
|
337
|
+
video: () => <video controls src={ mediaUrl } />,
|
|
338
|
+
};
|
|
339
|
+
const className = clsx( {
|
|
340
|
+
'has-media-on-the-right': 'right' === mediaPosition,
|
|
341
|
+
'is-stacked-on-mobile': isStackedOnMobile,
|
|
342
|
+
[ `is-vertically-aligned-${ verticalAlignment }` ]:
|
|
343
|
+
verticalAlignment,
|
|
344
|
+
'is-image-fill': imageFill,
|
|
345
|
+
} );
|
|
346
|
+
const backgroundStyles = imageFill
|
|
347
|
+
? v6ToV7ImageFillStyles( mediaUrl, focalPoint )
|
|
348
|
+
: {};
|
|
349
|
+
|
|
350
|
+
let gridTemplateColumns;
|
|
351
|
+
if ( mediaWidth !== DEFAULT_MEDIA_WIDTH ) {
|
|
352
|
+
gridTemplateColumns =
|
|
353
|
+
'right' === mediaPosition
|
|
354
|
+
? `auto ${ mediaWidth }%`
|
|
355
|
+
: `${ mediaWidth }% auto`;
|
|
356
|
+
}
|
|
357
|
+
const style = {
|
|
358
|
+
gridTemplateColumns,
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
if ( 'right' === mediaPosition ) {
|
|
362
|
+
return (
|
|
363
|
+
<div { ...useBlockProps.save( { className, style } ) }>
|
|
364
|
+
<div
|
|
365
|
+
{ ...useInnerBlocksProps.save( {
|
|
366
|
+
className: 'wp-block-media-text__content',
|
|
367
|
+
} ) }
|
|
368
|
+
/>
|
|
369
|
+
<figure
|
|
370
|
+
className="wp-block-media-text__media"
|
|
371
|
+
style={ backgroundStyles }
|
|
372
|
+
>
|
|
373
|
+
{ ( mediaTypeRenders[ mediaType ] || noop )() }
|
|
374
|
+
</figure>
|
|
375
|
+
</div>
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
return (
|
|
379
|
+
<div { ...useBlockProps.save( { className, style } ) }>
|
|
380
|
+
<figure
|
|
381
|
+
className="wp-block-media-text__media"
|
|
382
|
+
style={ backgroundStyles }
|
|
383
|
+
>
|
|
384
|
+
{ ( mediaTypeRenders[ mediaType ] || noop )() }
|
|
385
|
+
</figure>
|
|
386
|
+
<div
|
|
387
|
+
{ ...useInnerBlocksProps.save( {
|
|
388
|
+
className: 'wp-block-media-text__content',
|
|
389
|
+
} ) }
|
|
390
|
+
/>
|
|
391
|
+
</div>
|
|
392
|
+
);
|
|
393
|
+
},
|
|
394
|
+
};
|
|
395
|
+
|
|
240
396
|
// Version with wide as the default alignment.
|
|
241
397
|
// See: https://github.com/WordPress/gutenberg/pull/48404
|
|
242
398
|
const v6 = {
|
|
@@ -301,7 +457,7 @@ const v6 = {
|
|
|
301
457
|
'is-image-fill': imageFill,
|
|
302
458
|
} );
|
|
303
459
|
const backgroundStyles = imageFill
|
|
304
|
-
?
|
|
460
|
+
? v6ToV7ImageFillStyles( mediaUrl, focalPoint )
|
|
305
461
|
: {};
|
|
306
462
|
|
|
307
463
|
let gridTemplateColumns;
|
|
@@ -902,4 +1058,4 @@ const v1 = {
|
|
|
902
1058
|
},
|
|
903
1059
|
};
|
|
904
1060
|
|
|
905
|
-
export default [ v6, v5, v4, v3, v2, v1 ];
|
|
1061
|
+
export default [ v7, v6, v5, v4, v3, v2, v1 ];
|
package/src/media-text/edit.js
CHANGED
|
@@ -213,11 +213,11 @@ function MediaTextEdit( {
|
|
|
213
213
|
[ isSelected, mediaId ]
|
|
214
214
|
);
|
|
215
215
|
|
|
216
|
-
const
|
|
216
|
+
const refMedia = useRef();
|
|
217
217
|
const imperativeFocalPointPreview = ( value ) => {
|
|
218
|
-
const { style } =
|
|
218
|
+
const { style } = refMedia.current;
|
|
219
219
|
const { x, y } = value;
|
|
220
|
-
style.
|
|
220
|
+
style.objectPosition = `${ x * 100 }% ${ y * 100 }%`;
|
|
221
221
|
};
|
|
222
222
|
|
|
223
223
|
const [ temporaryMediaWidth, setTemporaryMediaWidth ] = useState( null );
|
|
@@ -243,7 +243,7 @@ function MediaTextEdit( {
|
|
|
243
243
|
'is-selected': isSelected,
|
|
244
244
|
'is-stacked-on-mobile': isStackedOnMobile,
|
|
245
245
|
[ `is-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,
|
|
246
|
-
'is-image-fill': imageFill,
|
|
246
|
+
'is-image-fill-element': imageFill,
|
|
247
247
|
} );
|
|
248
248
|
const widthString = `${ temporaryMediaWidth || mediaWidth }%`;
|
|
249
249
|
const gridTemplateColumns =
|
|
@@ -480,7 +480,7 @@ function MediaTextEdit( {
|
|
|
480
480
|
onSelectMedia={ onSelectMedia }
|
|
481
481
|
onWidthChange={ onWidthChange }
|
|
482
482
|
commitWidthChange={ commitWidthChange }
|
|
483
|
-
|
|
483
|
+
refMedia={ refMedia }
|
|
484
484
|
enableResize={ blockEditingMode === 'default' }
|
|
485
485
|
toggleUseFeaturedImage={ toggleUseFeaturedImage }
|
|
486
486
|
{ ...{
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
.wp-block-media-text.is-image-fill .editor-media-container__resizer,
|
|
30
|
-
.wp-block-media-text.is-image-fill .components-placeholder.has-illustration
|
|
30
|
+
.wp-block-media-text.is-image-fill .components-placeholder.has-illustration,
|
|
31
|
+
.wp-block-media-text.is-image-fill-element .editor-media-container__resizer,
|
|
32
|
+
.wp-block-media-text.is-image-fill-element .components-placeholder.has-illustration {
|
|
31
33
|
// The resizer sets an inline height but for the image fill we set it to full height.
|
|
32
34
|
height: 100% !important;
|
|
33
35
|
}
|