@wordpress/block-library 8.30.0 → 8.32.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/block/edit.js +22 -16
- package/build/block/edit.js.map +1 -1
- package/build/button/edit.native.js +1 -1
- package/build/button/edit.native.js.map +1 -1
- package/build/code/save.js +3 -1
- package/build/code/save.js.map +1 -1
- package/build/cover/edit/index.js +2 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/details/edit.js +1 -0
- package/build/details/edit.js.map +1 -1
- package/build/file/edit.js +2 -0
- package/build/file/edit.js.map +1 -1
- package/build/heading/index.js +4 -3
- package/build/heading/index.js.map +1 -1
- package/build/image/edit.js +10 -39
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +27 -6
- package/build/image/image.js.map +1 -1
- package/build/media-text/edit.js +33 -9
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/index.js +5 -0
- package/build/media-text/index.js.map +1 -1
- package/build/media-text/media-container.js +30 -11
- package/build/media-text/media-container.js.map +1 -1
- package/build/media-text/save.js +2 -2
- package/build/media-text/save.js.map +1 -1
- package/build/navigation/edit/index.js +23 -29
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-delete-control.js +12 -20
- package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +24 -23
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +4 -4
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +15 -12
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation/view.js +12 -2
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +52 -27
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +31 -9
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/pattern/edit.js +3 -1
- package/build/pattern/edit.js.map +1 -1
- package/build/post-author/edit.js +1 -0
- package/build/post-author/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +1 -0
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +16 -4
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-featured-image/index.js +13 -2
- package/build/post-featured-image/index.js.map +1 -1
- package/build/post-featured-image/overlay-controls.js +82 -0
- package/build/post-featured-image/overlay-controls.js.map +1 -0
- package/build/post-featured-image/overlay.js +5 -54
- package/build/post-featured-image/overlay.js.map +1 -1
- package/build/post-navigation-link/edit.js +1 -0
- package/build/post-navigation-link/edit.js.map +1 -1
- package/build/post-terms/edit.js +2 -0
- package/build/post-terms/edit.js.map +1 -1
- package/build/quote/edit.js +18 -23
- package/build/quote/edit.js.map +1 -1
- package/build/read-more/edit.js +1 -0
- package/build/read-more/edit.js.map +1 -1
- package/build/search/edit.js +2 -0
- package/build/search/edit.js.map +1 -1
- package/build/search/edit.native.js +2 -2
- package/build/search/edit.native.js.map +1 -1
- package/build/site-tagline/edit.js +13 -4
- package/build/site-tagline/edit.js.map +1 -1
- package/build/site-tagline/index.js +4 -0
- package/build/site-tagline/index.js.map +1 -1
- package/build/social-link/edit.js +1 -1
- package/build/social-link/edit.js.map +1 -1
- package/build/social-link/icons/medium.js +1 -1
- package/build/social-link/icons/medium.js.map +1 -1
- package/build/social-link/icons/reddit.js +1 -1
- package/build/social-link/icons/reddit.js.map +1 -1
- package/build/table/deprecated.js +285 -175
- package/build/table/deprecated.js.map +1 -1
- package/build/table/index.js +1 -1
- package/build/template-part/edit/index.js +55 -47
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/inner-blocks.js +106 -10
- package/build/template-part/edit/inner-blocks.js.map +1 -1
- package/build/template-part/edit/selection-modal.js +1 -9
- package/build/template-part/edit/selection-modal.js.map +1 -1
- package/build/utils/caption.js +19 -13
- package/build/utils/caption.js.map +1 -1
- package/build/utils/hooks.js +1 -0
- package/build/utils/hooks.js.map +1 -1
- package/build/video/edit.native.js +1 -1
- package/build/video/edit.native.js.map +1 -1
- package/build-module/block/edit.js +23 -17
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/edit.native.js +1 -1
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/code/save.js +3 -1
- package/build-module/code/save.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/details/edit.js +1 -0
- package/build-module/details/edit.js.map +1 -1
- package/build-module/file/edit.js +2 -0
- package/build-module/file/edit.js.map +1 -1
- package/build-module/heading/index.js +4 -3
- package/build-module/heading/index.js.map +1 -1
- package/build-module/image/edit.js +11 -40
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +27 -6
- package/build-module/image/image.js.map +1 -1
- package/build-module/media-text/edit.js +34 -10
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/index.js +5 -0
- package/build-module/media-text/index.js.map +1 -1
- package/build-module/media-text/media-container.js +31 -12
- package/build-module/media-text/media-container.js.map +1 -1
- package/build-module/media-text/save.js +2 -2
- package/build-module/media-text/save.js.map +1 -1
- package/build-module/navigation/edit/index.js +24 -30
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-delete-control.js +15 -23
- package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +24 -23
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +4 -4
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +15 -12
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation/view.js +12 -2
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +55 -30
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +31 -9
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/pattern/edit.js +3 -1
- package/build-module/pattern/edit.js.map +1 -1
- package/build-module/post-author/edit.js +1 -0
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +1 -0
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +17 -5
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-featured-image/index.js +13 -2
- package/build-module/post-featured-image/index.js.map +1 -1
- package/build-module/post-featured-image/overlay-controls.js +75 -0
- package/build-module/post-featured-image/overlay-controls.js.map +1 -0
- package/build-module/post-featured-image/overlay.js +7 -56
- package/build-module/post-featured-image/overlay.js.map +1 -1
- package/build-module/post-navigation-link/edit.js +1 -0
- package/build-module/post-navigation-link/edit.js.map +1 -1
- package/build-module/post-terms/edit.js +2 -0
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/quote/edit.js +20 -25
- package/build-module/quote/edit.js.map +1 -1
- package/build-module/read-more/edit.js +1 -0
- package/build-module/read-more/edit.js.map +1 -1
- package/build-module/search/edit.js +2 -0
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/edit.native.js +2 -2
- package/build-module/search/edit.native.js.map +1 -1
- package/build-module/site-tagline/edit.js +14 -5
- package/build-module/site-tagline/edit.js.map +1 -1
- package/build-module/site-tagline/index.js +4 -0
- package/build-module/site-tagline/index.js.map +1 -1
- package/build-module/social-link/edit.js +1 -1
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-link/icons/medium.js +1 -1
- package/build-module/social-link/icons/medium.js.map +1 -1
- package/build-module/social-link/icons/reddit.js +1 -1
- package/build-module/social-link/icons/reddit.js.map +1 -1
- package/build-module/table/deprecated.js +286 -176
- package/build-module/table/deprecated.js.map +1 -1
- package/build-module/table/index.js +1 -1
- package/build-module/template-part/edit/index.js +58 -50
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/inner-blocks.js +108 -12
- package/build-module/template-part/edit/inner-blocks.js.map +1 -1
- package/build-module/template-part/edit/selection-modal.js +2 -10
- package/build-module/template-part/edit/selection-modal.js.map +1 -1
- package/build-module/utils/caption.js +19 -13
- package/build-module/utils/caption.js.map +1 -1
- package/build-module/utils/hooks.js +1 -0
- package/build-module/utils/hooks.js.map +1 -1
- package/build-module/video/edit.native.js +1 -1
- package/build-module/video/edit.native.js.map +1 -1
- package/build-style/audio/theme-rtl.css +1 -1
- package/build-style/audio/theme.css +1 -1
- package/build-style/cover/style-rtl.css +5 -2
- package/build-style/cover/style.css +5 -2
- package/build-style/editor-rtl.css +22 -12
- package/build-style/editor.css +22 -12
- package/build-style/embed/theme-rtl.css +1 -1
- package/build-style/embed/theme.css +1 -1
- package/build-style/file/editor-rtl.css +3 -0
- package/build-style/file/editor.css +3 -0
- package/build-style/image/editor-rtl.css +0 -3
- package/build-style/image/editor.css +0 -3
- package/build-style/image/theme-rtl.css +1 -1
- package/build-style/image/theme.css +1 -1
- package/build-style/media-text/editor-rtl.css +7 -1
- package/build-style/media-text/editor.css +7 -1
- package/build-style/pullquote/theme-rtl.css +2 -1
- package/build-style/pullquote/theme.css +2 -1
- package/build-style/quote/theme-rtl.css +6 -6
- package/build-style/quote/theme.css +6 -6
- package/build-style/search/style-rtl.css +10 -0
- package/build-style/search/style.css +10 -0
- package/build-style/social-links/editor-rtl.css +0 -4
- package/build-style/social-links/editor.css +0 -4
- package/build-style/social-links/style-rtl.css +2 -2
- package/build-style/social-links/style.css +2 -2
- package/build-style/style-rtl.css +17 -4
- package/build-style/style.css +17 -4
- package/build-style/table/theme-rtl.css +4 -3
- package/build-style/table/theme.css +4 -3
- package/build-style/template-part/editor-rtl.css +12 -4
- package/build-style/template-part/editor.css +12 -4
- package/build-style/template-part/theme-rtl.css +1 -1
- package/build-style/template-part/theme.css +1 -1
- package/build-style/theme-rtl.css +17 -15
- package/build-style/theme.css +17 -15
- package/build-style/video/theme-rtl.css +1 -1
- package/build-style/video/theme.css +1 -1
- package/package.json +34 -34
- package/src/archives/index.php +4 -0
- package/src/audio/theme.scss +1 -1
- package/src/avatar/index.php +6 -0
- package/src/block/edit.js +43 -32
- package/src/block/index.php +4 -0
- package/src/block/test/edit.native.js +67 -0
- package/src/button/edit.native.js +1 -1
- package/src/calendar/index.php +12 -0
- package/src/categories/index.php +6 -0
- package/src/code/save.js +7 -1
- package/src/comment-author-name/index.php +4 -0
- package/src/comment-content/index.php +4 -0
- package/src/comment-date/index.php +4 -0
- package/src/comment-edit-link/index.php +4 -0
- package/src/comment-reply-link/index.php +4 -0
- package/src/comment-template/index.php +4 -0
- package/src/comments/index.php +10 -0
- package/src/comments-pagination/index.php +4 -0
- package/src/comments-pagination-next/index.php +4 -0
- package/src/comments-pagination-numbers/index.php +4 -0
- package/src/comments-pagination-previous/index.php +4 -0
- package/src/comments-title/index.php +4 -0
- package/src/cover/edit/index.js +4 -1
- package/src/cover/index.php +4 -0
- package/src/cover/style.scss +6 -2
- package/src/details/edit.js +1 -0
- package/src/embed/theme.scss +1 -1
- package/src/file/edit.js +2 -0
- package/src/file/editor.scss +3 -0
- package/src/file/index.php +4 -0
- package/src/gallery/editor.scss +1 -1
- package/src/gallery/index.php +7 -1
- package/src/heading/index.js +4 -3
- package/src/heading/index.php +4 -0
- package/src/home-link/index.php +10 -0
- package/src/image/edit.js +11 -40
- package/src/image/editor.scss +2 -7
- package/src/image/image.js +25 -7
- package/src/image/index.php +12 -1
- package/src/image/theme.scss +1 -1
- package/src/latest-comments/index.php +4 -0
- package/src/latest-posts/index.php +8 -0
- package/src/loginout/index.php +4 -0
- package/src/media-text/block.json +5 -0
- package/src/media-text/edit.js +70 -19
- package/src/media-text/editor.scss +7 -1
- package/src/media-text/index.php +70 -0
- package/src/media-text/media-container.js +49 -9
- package/src/media-text/save.js +2 -2
- package/src/navigation/edit/index.js +67 -71
- package/src/navigation/edit/navigation-menu-delete-control.js +22 -49
- package/src/navigation/edit/navigation-menu-selector.js +39 -21
- package/src/navigation/edit/placeholder/index.js +4 -4
- package/src/navigation/edit/test/navigation-menu-selector.js +75 -53
- package/src/navigation/index.php +109 -26
- package/src/navigation/test/use-navigation-menu.js +21 -21
- package/src/navigation/use-navigation-menu.js +23 -9
- package/src/navigation/view.js +11 -2
- package/src/navigation-link/edit.js +64 -39
- package/src/navigation-link/index.php +14 -0
- package/src/navigation-submenu/edit.js +34 -10
- package/src/navigation-submenu/index.php +8 -0
- package/src/page-list/index.php +12 -0
- package/src/page-list-item/index.php +2 -0
- package/src/pattern/edit.js +4 -0
- package/src/pattern/index.php +2 -0
- package/src/post-author/edit.js +1 -0
- package/src/post-author/index.php +4 -0
- package/src/post-author-biography/index.php +4 -0
- package/src/post-author-name/index.php +4 -0
- package/src/post-comments-form/index.php +6 -0
- package/src/post-content/index.php +4 -0
- package/src/post-date/index.php +4 -0
- package/src/post-excerpt/edit.js +1 -0
- package/src/post-excerpt/index.php +4 -0
- package/src/post-featured-image/block.json +13 -2
- package/src/post-featured-image/edit.js +16 -1
- package/src/post-featured-image/editor.scss +1 -1
- package/src/post-featured-image/index.php +15 -0
- package/src/post-featured-image/overlay-controls.js +88 -0
- package/src/post-featured-image/overlay.js +17 -84
- package/src/post-navigation-link/edit.js +1 -0
- package/src/post-navigation-link/index.php +4 -0
- package/src/post-template/index.php +4 -0
- package/src/post-terms/edit.js +2 -0
- package/src/post-terms/index.php +6 -0
- package/src/post-title/index.php +2 -0
- package/src/pullquote/theme.scss +3 -1
- package/src/query/index.php +2 -0
- package/src/query-no-results/index.php +6 -0
- package/src/query-pagination/index.php +4 -0
- package/src/query-pagination-next/index.php +6 -0
- package/src/query-pagination-numbers/index.php +6 -0
- package/src/query-pagination-previous/index.php +4 -0
- package/src/query-title/index.php +4 -0
- package/src/quote/edit.js +27 -37
- package/src/quote/test/edit.native.js +4 -6
- package/src/quote/theme.scss +1 -2
- package/src/read-more/edit.js +1 -0
- package/src/read-more/index.php +4 -0
- package/src/rss/index.php +4 -0
- package/src/search/edit.js +2 -0
- package/src/search/edit.native.js +2 -2
- package/src/search/index.php +19 -1
- package/src/search/style.scss +11 -0
- package/src/shortcode/index.php +4 -0
- package/src/site-logo/editor.scss +2 -2
- package/src/site-logo/index.php +20 -0
- package/src/site-tagline/block.json +4 -0
- package/src/site-tagline/edit.js +16 -3
- package/src/site-tagline/index.php +13 -1
- package/src/site-title/index.php +4 -0
- package/src/social-link/edit.js +1 -1
- package/src/social-link/icons/medium.js +1 -1
- package/src/social-link/icons/reddit.js +1 -1
- package/src/social-link/index.php +22 -9
- package/src/social-link/socials-with-bg.scss +1 -1
- package/src/social-link/socials-without-bg.scss +1 -1
- package/src/social-links/editor.scss +1 -9
- package/src/table/block.json +1 -1
- package/src/table/deprecated.js +308 -175
- package/src/table/theme.scss +4 -2
- package/src/tag-cloud/index.php +4 -0
- package/src/template-part/edit/index.js +87 -79
- package/src/template-part/edit/inner-blocks.js +126 -13
- package/src/template-part/edit/selection-modal.js +1 -22
- package/src/template-part/editor.scss +11 -3
- package/src/template-part/index.php +12 -0
- package/src/template-part/theme.scss +1 -1
- package/src/term-description/index.php +4 -0
- package/src/utils/caption.js +19 -16
- package/src/utils/hooks.js +1 -0
- package/src/video/edit.native.js +2 -0
- package/src/video/editor.scss +2 -2
- package/src/video/theme.scss +1 -1
- package/tsconfig.json +1 -0
package/src/calendar/index.php
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/calendar` block on server.
|
|
10
10
|
*
|
|
11
|
+
* @since 5.2.0
|
|
12
|
+
*
|
|
11
13
|
* @global int $monthnum.
|
|
12
14
|
* @global int $year.
|
|
13
15
|
*
|
|
@@ -79,6 +81,8 @@ function render_block_core_calendar( $attributes ) {
|
|
|
79
81
|
|
|
80
82
|
/**
|
|
81
83
|
* Registers the `core/calendar` block on server.
|
|
84
|
+
*
|
|
85
|
+
* @since 5.2.0
|
|
82
86
|
*/
|
|
83
87
|
function register_block_core_calendar() {
|
|
84
88
|
register_block_type_from_metadata(
|
|
@@ -97,6 +101,8 @@ add_action( 'init', 'register_block_core_calendar' );
|
|
|
97
101
|
* Used to hide the calendar block when there are no published posts.
|
|
98
102
|
* This compensates for a known Core bug: https://core.trac.wordpress.org/ticket/12016
|
|
99
103
|
*
|
|
104
|
+
* @since 5.9.0
|
|
105
|
+
*
|
|
100
106
|
* @return bool Has any published posts or not.
|
|
101
107
|
*/
|
|
102
108
|
function block_core_calendar_has_published_posts() {
|
|
@@ -120,6 +126,8 @@ function block_core_calendar_has_published_posts() {
|
|
|
120
126
|
* Queries the database for any published post and saves
|
|
121
127
|
* a flag whether any published post exists or not.
|
|
122
128
|
*
|
|
129
|
+
* @since 5.9.0
|
|
130
|
+
*
|
|
123
131
|
* @global wpdb $wpdb WordPress database abstraction object.
|
|
124
132
|
*
|
|
125
133
|
* @return bool Has any published posts or not.
|
|
@@ -137,6 +145,8 @@ if ( ! is_multisite() ) {
|
|
|
137
145
|
/**
|
|
138
146
|
* Handler for updating the has published posts flag when a post is deleted.
|
|
139
147
|
*
|
|
148
|
+
* @since 5.9.0
|
|
149
|
+
*
|
|
140
150
|
* @param int $post_id Deleted post ID.
|
|
141
151
|
*/
|
|
142
152
|
function block_core_calendar_update_has_published_post_on_delete( $post_id ) {
|
|
@@ -152,6 +162,8 @@ if ( ! is_multisite() ) {
|
|
|
152
162
|
/**
|
|
153
163
|
* Handler for updating the has published posts flag when a post status changes.
|
|
154
164
|
*
|
|
165
|
+
* @since 5.9.0
|
|
166
|
+
*
|
|
155
167
|
* @param string $new_status The status the post is changing to.
|
|
156
168
|
* @param string $old_status The status the post is changing from.
|
|
157
169
|
* @param WP_Post $post Post object.
|
package/src/categories/index.php
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/categories` block on server.
|
|
10
10
|
*
|
|
11
|
+
* @since 5.0.0
|
|
12
|
+
*
|
|
11
13
|
* @param array $attributes The block attributes.
|
|
12
14
|
*
|
|
13
15
|
* @return string Returns the categories list/dropdown markup.
|
|
@@ -63,6 +65,8 @@ function render_block_core_categories( $attributes ) {
|
|
|
63
65
|
/**
|
|
64
66
|
* Generates the inline script for a categories dropdown field.
|
|
65
67
|
*
|
|
68
|
+
* @since 5.0.0
|
|
69
|
+
*
|
|
66
70
|
* @param string $dropdown_id ID of the dropdown field.
|
|
67
71
|
*
|
|
68
72
|
* @return string Returns the dropdown onChange redirection script.
|
|
@@ -87,6 +91,8 @@ function build_dropdown_script_block_core_categories( $dropdown_id ) {
|
|
|
87
91
|
|
|
88
92
|
/**
|
|
89
93
|
* Registers the `core/categories` block on server.
|
|
94
|
+
*
|
|
95
|
+
* @since 5.0.0
|
|
90
96
|
*/
|
|
91
97
|
function register_block_core_categories() {
|
|
92
98
|
register_block_type_from_metadata(
|
package/src/code/save.js
CHANGED
|
@@ -16,7 +16,13 @@ export default function save( { attributes } ) {
|
|
|
16
16
|
// To do: `escape` encodes characters in shortcodes and URLs to
|
|
17
17
|
// prevent embedding in PHP. Ideally checks for the code block,
|
|
18
18
|
// or pre/code tags, should be made on the PHP side?
|
|
19
|
-
value={ escape(
|
|
19
|
+
value={ escape(
|
|
20
|
+
typeof attributes.content === 'string'
|
|
21
|
+
? attributes.content
|
|
22
|
+
: attributes.content.toHTMLString( {
|
|
23
|
+
preserveWhiteSpace: true,
|
|
24
|
+
} )
|
|
25
|
+
) }
|
|
20
26
|
/>
|
|
21
27
|
</pre>
|
|
22
28
|
);
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/comment-author-name` block on the server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.0.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.
|
|
@@ -53,6 +55,8 @@ function render_block_core_comment_author_name( $attributes, $content, $block )
|
|
|
53
55
|
|
|
54
56
|
/**
|
|
55
57
|
* Registers the `core/comment-author-name` block on the server.
|
|
58
|
+
*
|
|
59
|
+
* @since 6.0.0
|
|
56
60
|
*/
|
|
57
61
|
function register_block_core_comment_author_name() {
|
|
58
62
|
register_block_type_from_metadata(
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/comment-content` block on the server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.0.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.
|
|
@@ -69,6 +71,8 @@ function render_block_core_comment_content( $attributes, $content, $block ) {
|
|
|
69
71
|
|
|
70
72
|
/**
|
|
71
73
|
* Registers the `core/comment-content` block on the server.
|
|
74
|
+
*
|
|
75
|
+
* @since 6.0.0
|
|
72
76
|
*/
|
|
73
77
|
function register_block_core_comment_content() {
|
|
74
78
|
register_block_type_from_metadata(
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/comment-date` block on the server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.0.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.
|
|
@@ -46,6 +48,8 @@ function render_block_core_comment_date( $attributes, $content, $block ) {
|
|
|
46
48
|
|
|
47
49
|
/**
|
|
48
50
|
* Registers the `core/comment-date` block on the server.
|
|
51
|
+
*
|
|
52
|
+
* @since 6.0.0
|
|
49
53
|
*/
|
|
50
54
|
function register_block_core_comment_date() {
|
|
51
55
|
register_block_type_from_metadata(
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/comment-edit-link` block on the server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.0.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.
|
|
@@ -48,6 +50,8 @@ function render_block_core_comment_edit_link( $attributes, $content, $block ) {
|
|
|
48
50
|
|
|
49
51
|
/**
|
|
50
52
|
* Registers the `core/comment-edit-link` block on the server.
|
|
53
|
+
*
|
|
54
|
+
* @since 6.0.0
|
|
51
55
|
*/
|
|
52
56
|
function register_block_core_comment_edit_link() {
|
|
53
57
|
register_block_type_from_metadata(
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/comment-reply-link` block on the server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.0.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.
|
|
@@ -70,6 +72,8 @@ function render_block_core_comment_reply_link( $attributes, $content, $block ) {
|
|
|
70
72
|
|
|
71
73
|
/**
|
|
72
74
|
* Registers the `core/comment-reply-link` block on the server.
|
|
75
|
+
*
|
|
76
|
+
* @since 6.0.0
|
|
73
77
|
*/
|
|
74
78
|
function register_block_core_comment_reply_link() {
|
|
75
79
|
register_block_type_from_metadata(
|
|
@@ -92,6 +92,8 @@ function block_core_comment_template_render_comments( $comments, $block ) {
|
|
|
92
92
|
/**
|
|
93
93
|
* Renders the `core/comment-template` block on the server.
|
|
94
94
|
*
|
|
95
|
+
* @since 6.0.0
|
|
96
|
+
*
|
|
95
97
|
* @param array $attributes Block attributes.
|
|
96
98
|
* @param string $content Block default content.
|
|
97
99
|
* @param WP_Block $block Block instance.
|
|
@@ -136,6 +138,8 @@ function render_block_core_comment_template( $attributes, $content, $block ) {
|
|
|
136
138
|
|
|
137
139
|
/**
|
|
138
140
|
* Registers the `core/comment-template` block on the server.
|
|
141
|
+
*
|
|
142
|
+
* @since 6.0.0
|
|
139
143
|
*/
|
|
140
144
|
function register_block_core_comment_template() {
|
|
141
145
|
register_block_type_from_metadata(
|
package/src/comments/index.php
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* the block is in legacy mode. If not, the HTML generated in the editor is
|
|
17
17
|
* returned instead.
|
|
18
18
|
*
|
|
19
|
+
* @since 6.1.0
|
|
20
|
+
*
|
|
19
21
|
* @global WP_Post $post Global post object.
|
|
20
22
|
*
|
|
21
23
|
* @param array $attributes Block attributes.
|
|
@@ -85,6 +87,8 @@ function render_block_core_comments( $attributes, $content, $block ) {
|
|
|
85
87
|
|
|
86
88
|
/**
|
|
87
89
|
* Registers the `core/comments` block on the server.
|
|
90
|
+
*
|
|
91
|
+
* @since 6.1.0
|
|
88
92
|
*/
|
|
89
93
|
function register_block_core_comments() {
|
|
90
94
|
register_block_type_from_metadata(
|
|
@@ -100,6 +104,8 @@ add_action( 'init', 'register_block_core_comments' );
|
|
|
100
104
|
/**
|
|
101
105
|
* Use the button block classes for the form-submit button.
|
|
102
106
|
*
|
|
107
|
+
* @since 6.1.0
|
|
108
|
+
*
|
|
103
109
|
* @param array $fields The default comment form arguments.
|
|
104
110
|
*
|
|
105
111
|
* @return array Returns the modified fields.
|
|
@@ -118,6 +124,8 @@ add_filter( 'comment_form_defaults', 'comments_block_form_defaults' );
|
|
|
118
124
|
* Enqueues styles from the legacy `core/post-comments` block. These styles are
|
|
119
125
|
* required only by the block's fallback.
|
|
120
126
|
*
|
|
127
|
+
* @since 6.1.0
|
|
128
|
+
*
|
|
121
129
|
* @param string $block_name Name of the new block type.
|
|
122
130
|
*/
|
|
123
131
|
function enqueue_legacy_post_comments_block_styles( $block_name ) {
|
|
@@ -143,6 +151,8 @@ function enqueue_legacy_post_comments_block_styles( $block_name ) {
|
|
|
143
151
|
* The same approach was followed when core/query-loop was renamed to
|
|
144
152
|
* core/post-template.
|
|
145
153
|
*
|
|
154
|
+
* @since 6.1.0
|
|
155
|
+
*
|
|
146
156
|
* @see https://github.com/WordPress/gutenberg/pull/41807
|
|
147
157
|
* @see https://github.com/WordPress/gutenberg/pull/32514
|
|
148
158
|
*/
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/comments-pagination` block on the server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.0.0
|
|
12
|
+
*
|
|
11
13
|
* @param array $attributes Block attributes.
|
|
12
14
|
* @param string $content Block default content.
|
|
13
15
|
*
|
|
@@ -34,6 +36,8 @@ function render_block_core_comments_pagination( $attributes, $content ) {
|
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* Registers the `core/comments-pagination` block on the server.
|
|
39
|
+
*
|
|
40
|
+
* @since 6.0.0
|
|
37
41
|
*/
|
|
38
42
|
function register_block_core_comments_pagination() {
|
|
39
43
|
register_block_type_from_metadata(
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/comments-pagination-next` block on the server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.0.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.
|
|
@@ -48,6 +50,8 @@ function render_block_core_comments_pagination_next( $attributes, $content, $blo
|
|
|
48
50
|
|
|
49
51
|
/**
|
|
50
52
|
* Registers the `core/comments-pagination-next` block on the server.
|
|
53
|
+
*
|
|
54
|
+
* @since 6.0.0
|
|
51
55
|
*/
|
|
52
56
|
function register_block_core_comments_pagination_next() {
|
|
53
57
|
register_block_type_from_metadata(
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/comments-pagination-numbers` block on the server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.0.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.
|
|
@@ -50,6 +52,8 @@ function render_block_core_comments_pagination_numbers( $attributes, $content, $
|
|
|
50
52
|
|
|
51
53
|
/**
|
|
52
54
|
* Registers the `core/comments-pagination-numbers` block on the server.
|
|
55
|
+
*
|
|
56
|
+
* @since 6.0.0
|
|
53
57
|
*/
|
|
54
58
|
function register_block_core_comments_pagination_numbers() {
|
|
55
59
|
register_block_type_from_metadata(
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/comments-pagination-previous` block on the server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.0.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.
|
|
@@ -40,6 +42,8 @@ function render_block_core_comments_pagination_previous( $attributes, $content,
|
|
|
40
42
|
|
|
41
43
|
/**
|
|
42
44
|
* Registers the `core/comments-pagination-previous` block on the server.
|
|
45
|
+
*
|
|
46
|
+
* @since 6.0.0
|
|
43
47
|
*/
|
|
44
48
|
function register_block_core_comments_pagination_previous() {
|
|
45
49
|
register_block_type_from_metadata(
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/comments-title` block on the server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.0.0
|
|
12
|
+
*
|
|
11
13
|
* @param array $attributes Block attributes.
|
|
12
14
|
*
|
|
13
15
|
* @return string Return the post comments title.
|
|
@@ -84,6 +86,8 @@ function render_block_core_comments_title( $attributes ) {
|
|
|
84
86
|
|
|
85
87
|
/**
|
|
86
88
|
* Registers the `core/comments-title` block on the server.
|
|
89
|
+
*
|
|
90
|
+
* @since 6.0.0
|
|
87
91
|
*/
|
|
88
92
|
function register_block_core_comments_title() {
|
|
89
93
|
register_block_type_from_metadata(
|
package/src/cover/edit/index.js
CHANGED
|
@@ -489,6 +489,9 @@ function CoverEdit( {
|
|
|
489
489
|
getPositionClassName( contentPosition )
|
|
490
490
|
);
|
|
491
491
|
|
|
492
|
+
const showOverlay =
|
|
493
|
+
url || ! useFeaturedImage || ( useFeaturedImage && ! url );
|
|
494
|
+
|
|
492
495
|
return (
|
|
493
496
|
<>
|
|
494
497
|
{ blockControls }
|
|
@@ -500,7 +503,7 @@ function CoverEdit( {
|
|
|
500
503
|
data-url={ url }
|
|
501
504
|
>
|
|
502
505
|
{ resizeListener }
|
|
503
|
-
{
|
|
506
|
+
{ showOverlay && (
|
|
504
507
|
<span
|
|
505
508
|
aria-hidden="true"
|
|
506
509
|
className={ classnames(
|
package/src/cover/index.php
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/cover` block on server.
|
|
10
10
|
*
|
|
11
|
+
* @since 6.0.0
|
|
12
|
+
*
|
|
11
13
|
* @param array $attributes The block attributes.
|
|
12
14
|
* @param string $content The block rendered content.
|
|
13
15
|
*
|
|
@@ -66,6 +68,8 @@ function render_block_core_cover( $attributes, $content ) {
|
|
|
66
68
|
|
|
67
69
|
/**
|
|
68
70
|
* Registers the `core/cover` block renderer on server.
|
|
71
|
+
*
|
|
72
|
+
* @since 6.0.0
|
|
69
73
|
*/
|
|
70
74
|
function register_block_core_cover() {
|
|
71
75
|
register_block_type_from_metadata(
|
package/src/cover/style.scss
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
// Lowest specificity styles are used to ensure that the default styles for the cover block can be overridden by global styles.
|
|
2
|
+
:where(.wp-block-cover-image, .wp-block-cover) {
|
|
3
|
+
min-height: 430px;
|
|
4
|
+
padding: 1em;
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
.wp-block-cover-image,
|
|
2
8
|
.wp-block-cover {
|
|
3
9
|
position: relative;
|
|
4
10
|
background-position: center center;
|
|
5
|
-
min-height: 430px;
|
|
6
11
|
display: flex;
|
|
7
12
|
justify-content: center;
|
|
8
13
|
align-items: center;
|
|
9
|
-
padding: 1em;
|
|
10
14
|
// Prevent the `wp-block-cover__background` span from overflowing the container when border-radius is applied.
|
|
11
15
|
// `overflow: hidden` is provided as a fallback for browsers that don't support `overflow: clip`.
|
|
12
16
|
overflow: hidden;
|
package/src/details/edit.js
CHANGED
|
@@ -64,6 +64,7 @@ function DetailsEdit( { attributes, setAttributes, clientId } ) {
|
|
|
64
64
|
>
|
|
65
65
|
<summary onClick={ ( event ) => event.preventDefault() }>
|
|
66
66
|
<RichText
|
|
67
|
+
identifier="summary"
|
|
67
68
|
aria-label={ __( 'Write summary' ) }
|
|
68
69
|
placeholder={ __( 'Write summary…' ) }
|
|
69
70
|
allowedFormats={ [] }
|
package/src/embed/theme.scss
CHANGED
package/src/file/edit.js
CHANGED
|
@@ -254,6 +254,7 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
|
|
|
254
254
|
) }
|
|
255
255
|
<div className={ 'wp-block-file__content-wrapper' }>
|
|
256
256
|
<RichText
|
|
257
|
+
identifier="fileName"
|
|
257
258
|
tagName="a"
|
|
258
259
|
value={ fileName }
|
|
259
260
|
placeholder={ __( 'Write file name…' ) }
|
|
@@ -273,6 +274,7 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
|
|
|
273
274
|
>
|
|
274
275
|
{ /* Using RichText here instead of PlainText so that it can be styled like a button. */ }
|
|
275
276
|
<RichText
|
|
277
|
+
identifier="downloadButtonText"
|
|
276
278
|
tagName="div" // Must be block-level or else cursor disappears.
|
|
277
279
|
aria-label={ __( 'Download button text' ) }
|
|
278
280
|
className={ classnames(
|
package/src/file/editor.scss
CHANGED
package/src/file/index.php
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* When the `core/file` block is rendering, check if we need to enqueue the `wp-block-file-view` script.
|
|
10
10
|
*
|
|
11
|
+
* @since 5.8.0
|
|
12
|
+
*
|
|
11
13
|
* @param array $attributes The block attributes.
|
|
12
14
|
* @param string $content The block content.
|
|
13
15
|
* @param WP_Block $block The parsed block.
|
|
@@ -65,6 +67,8 @@ function render_block_core_file( $attributes, $content ) {
|
|
|
65
67
|
|
|
66
68
|
/**
|
|
67
69
|
* Registers the `core/file` block on server.
|
|
70
|
+
*
|
|
71
|
+
* @since 5.8.0
|
|
68
72
|
*/
|
|
69
73
|
function register_block_core_file() {
|
|
70
74
|
register_block_type_from_metadata(
|
package/src/gallery/editor.scss
CHANGED
|
@@ -27,7 +27,7 @@ figure.wp-block-gallery {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
// @todo
|
|
30
|
+
// @todo this deserves a refactor, by being moved to the toolbar.
|
|
31
31
|
.block-editor-media-placeholder.is-appender {
|
|
32
32
|
.components-placeholder__label {
|
|
33
33
|
display: none;
|
package/src/gallery/index.php
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* we add a custom `data-id` attribute before rendering the gallery
|
|
14
14
|
* so that the Image Block can pick it up in its render_callback.
|
|
15
15
|
*
|
|
16
|
+
* @since 5.9.0
|
|
17
|
+
*
|
|
16
18
|
* @param array $parsed_block The block being rendered.
|
|
17
19
|
* @return array The migrated block object.
|
|
18
20
|
*/
|
|
@@ -35,6 +37,8 @@ add_filter( 'render_block_data', 'block_core_gallery_data_id_backcompatibility'
|
|
|
35
37
|
/**
|
|
36
38
|
* Renders the `core/gallery` block on the server.
|
|
37
39
|
*
|
|
40
|
+
* @since 6.0.0
|
|
41
|
+
*
|
|
38
42
|
* @param array $attributes Attributes of the block being rendered.
|
|
39
43
|
* @param string $content Content of the block being rendered.
|
|
40
44
|
* @return string The content of the block being rendered.
|
|
@@ -127,7 +131,7 @@ function block_core_gallery_render( $attributes, $content ) {
|
|
|
127
131
|
* the `$parsed_block['innerBlocks']` via the `render_block_data` hook.
|
|
128
132
|
* However, this hook doesn't apply inner block updates when blocks are
|
|
129
133
|
* nested.
|
|
130
|
-
* @todo
|
|
134
|
+
* @todo In the future, if this hook supports updating innerBlocks in
|
|
131
135
|
* nested blocks, it should be refactored.
|
|
132
136
|
*
|
|
133
137
|
* @see: https://github.com/WordPress/gutenberg/pull/58733
|
|
@@ -164,6 +168,8 @@ function block_core_gallery_render( $attributes, $content ) {
|
|
|
164
168
|
}
|
|
165
169
|
/**
|
|
166
170
|
* Registers the `core/gallery` block on server.
|
|
171
|
+
*
|
|
172
|
+
* @since 5.9.0
|
|
167
173
|
*/
|
|
168
174
|
function register_block_core_gallery() {
|
|
169
175
|
register_block_type_from_metadata(
|
package/src/heading/index.js
CHANGED
|
@@ -30,15 +30,16 @@ export const settings = {
|
|
|
30
30
|
const { content, level } = attributes;
|
|
31
31
|
|
|
32
32
|
const customName = attributes?.metadata?.name;
|
|
33
|
+
const hasContent = content?.trim().length > 0;
|
|
33
34
|
|
|
34
35
|
// In the list view, use the block's content as the label.
|
|
35
36
|
// If the content is empty, fall back to the default label.
|
|
36
|
-
if ( context === 'list-view' && ( customName ||
|
|
37
|
-
return
|
|
37
|
+
if ( context === 'list-view' && ( customName || hasContent ) ) {
|
|
38
|
+
return customName || content;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
if ( context === 'accessibility' ) {
|
|
41
|
-
return !
|
|
42
|
+
return ! hasContent
|
|
42
43
|
? sprintf(
|
|
43
44
|
/* translators: accessibility text. %s: heading level. */
|
|
44
45
|
__( 'Level %s. Empty.' ),
|
package/src/heading/index.php
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* Would be transformed to:
|
|
15
15
|
* <h2 class="align-left wp-block-heading">Hello World</h2>
|
|
16
16
|
*
|
|
17
|
+
* @since 6.2.0
|
|
18
|
+
*
|
|
17
19
|
* @param array $attributes Attributes of the block being rendered.
|
|
18
20
|
* @param string $content Content of the block being rendered.
|
|
19
21
|
*
|
|
@@ -39,6 +41,8 @@ function block_core_heading_render( $attributes, $content ) {
|
|
|
39
41
|
|
|
40
42
|
/**
|
|
41
43
|
* Registers the `core/heading` block on server.
|
|
44
|
+
*
|
|
45
|
+
* @since 6.2.0
|
|
42
46
|
*/
|
|
43
47
|
function register_block_core_heading() {
|
|
44
48
|
register_block_type_from_metadata(
|
package/src/home-link/index.php
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* Build an array with CSS classes and inline styles defining the colors
|
|
10
10
|
* which will be applied to the home link markup in the front-end.
|
|
11
11
|
*
|
|
12
|
+
* @since 6.0.0
|
|
13
|
+
*
|
|
12
14
|
* @param array $context home link block context.
|
|
13
15
|
* @return array Colors CSS classes and inline styles.
|
|
14
16
|
*/
|
|
@@ -61,6 +63,8 @@ function block_core_home_link_build_css_colors( $context ) {
|
|
|
61
63
|
* Build an array with CSS classes and inline styles defining the font sizes
|
|
62
64
|
* which will be applied to the home link markup in the front-end.
|
|
63
65
|
*
|
|
66
|
+
* @since 6.0.0
|
|
67
|
+
*
|
|
64
68
|
* @param array $context Home link block context.
|
|
65
69
|
* @return array Font size CSS classes and inline styles.
|
|
66
70
|
*/
|
|
@@ -88,6 +92,8 @@ function block_core_home_link_build_css_font_sizes( $context ) {
|
|
|
88
92
|
/**
|
|
89
93
|
* Builds an array with classes and style for the li wrapper
|
|
90
94
|
*
|
|
95
|
+
* @since 6.0.0
|
|
96
|
+
*
|
|
91
97
|
* @param array $context Home link block context.
|
|
92
98
|
* @return string The li wrapper attributes.
|
|
93
99
|
*/
|
|
@@ -121,6 +127,8 @@ function block_core_home_link_build_li_wrapper_attributes( $context ) {
|
|
|
121
127
|
/**
|
|
122
128
|
* Renders the `core/home-link` block.
|
|
123
129
|
*
|
|
130
|
+
* @since 6.0.0
|
|
131
|
+
*
|
|
124
132
|
* @param array $attributes The block attributes.
|
|
125
133
|
* @param string $content The saved content.
|
|
126
134
|
* @param WP_Block $block The parsed block.
|
|
@@ -155,6 +163,8 @@ function render_block_core_home_link( $attributes, $content, $block ) {
|
|
|
155
163
|
/**
|
|
156
164
|
* Register the home block
|
|
157
165
|
*
|
|
166
|
+
* @since 6.0.0
|
|
167
|
+
*
|
|
158
168
|
* @uses render_block_core_home_link()
|
|
159
169
|
* @throws WP_Error An WP_Error exception parsing the block definition.
|
|
160
170
|
*/
|
package/src/image/edit.js
CHANGED
|
@@ -6,7 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { isBlobURL } from '@wordpress/blob';
|
|
10
10
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
11
11
|
import { Placeholder } from '@wordpress/components';
|
|
12
12
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
@@ -28,6 +28,7 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
28
28
|
* Internal dependencies
|
|
29
29
|
*/
|
|
30
30
|
import { unlock } from '../lock-unlock';
|
|
31
|
+
import { useUploadMediaFromBlobURL } from '../utils/hooks';
|
|
31
32
|
import Image from './image';
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -116,7 +117,9 @@ export function ImageEdit( {
|
|
|
116
117
|
align,
|
|
117
118
|
metadata,
|
|
118
119
|
} = attributes;
|
|
119
|
-
const [ temporaryURL, setTemporaryURL ] = useState()
|
|
120
|
+
const [ temporaryURL, setTemporaryURL ] = useState( () => {
|
|
121
|
+
return isTemporaryImage( id, url ) ? url : undefined;
|
|
122
|
+
} );
|
|
120
123
|
|
|
121
124
|
const altRef = useRef();
|
|
122
125
|
useEffect( () => {
|
|
@@ -267,44 +270,12 @@ export function ImageEdit( {
|
|
|
267
270
|
}
|
|
268
271
|
}
|
|
269
272
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const file = getBlobByURL( url );
|
|
279
|
-
|
|
280
|
-
if ( file ) {
|
|
281
|
-
const { mediaUpload } = getSettings();
|
|
282
|
-
if ( ! mediaUpload ) {
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
mediaUpload( {
|
|
286
|
-
filesList: [ file ],
|
|
287
|
-
onFileChange: ( [ img ] ) => {
|
|
288
|
-
onSelectImage( img );
|
|
289
|
-
},
|
|
290
|
-
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
291
|
-
onError: ( message ) => {
|
|
292
|
-
isTemp = false;
|
|
293
|
-
onUploadError( message );
|
|
294
|
-
},
|
|
295
|
-
} );
|
|
296
|
-
}
|
|
297
|
-
}, [] );
|
|
298
|
-
|
|
299
|
-
// If an image is temporary, revoke the Blob url when it is uploaded (and is
|
|
300
|
-
// no longer temporary).
|
|
301
|
-
useEffect( () => {
|
|
302
|
-
if ( isTemp ) {
|
|
303
|
-
setTemporaryURL( url );
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
revokeBlobURL( temporaryURL );
|
|
307
|
-
}, [ isTemp, url ] );
|
|
273
|
+
useUploadMediaFromBlobURL( {
|
|
274
|
+
url,
|
|
275
|
+
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
276
|
+
onChange: onSelectImage,
|
|
277
|
+
onError: onUploadError,
|
|
278
|
+
} );
|
|
308
279
|
|
|
309
280
|
const isExternal = isExternalImage( id, url );
|
|
310
281
|
const src = isExternal ? url : undefined;
|