@wordpress/block-library 7.15.1-next.4d3b314fd5.0 → 7.17.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 -1
- package/build/archives/edit.js +1 -0
- package/build/archives/edit.js.map +1 -1
- package/build/code/utils.js +3 -3
- package/build/code/utils.js.map +1 -1
- package/build/comment-template/edit.js +40 -32
- package/build/comment-template/edit.js.map +1 -1
- package/build/comments/edit/placeholder.js +1 -4
- package/build/comments/edit/placeholder.js.map +1 -1
- package/build/comments/index.js +5 -1
- package/build/comments/index.js.map +1 -1
- package/build/comments-title/edit.js +18 -1
- package/build/comments-title/edit.js.map +1 -1
- package/build/cover/edit/index.js +2 -2
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/use-cover-is-dark.js +8 -7
- package/build/cover/edit/use-cover-is-dark.js.map +1 -1
- package/build/embed/variations.js +1 -1
- package/build/embed/variations.js.map +1 -1
- package/build/gallery/transforms.js +3 -3
- package/build/gallery/transforms.js.map +1 -1
- package/build/gallery/v1/edit.js +1 -1
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/group/edit.js +1 -1
- package/build/group/edit.js.map +1 -1
- package/build/image/image.js +34 -10
- package/build/image/image.js.map +1 -1
- package/build/image/transforms.js +1 -7
- package/build/image/transforms.js.map +1 -1
- package/build/list/transforms.js +9 -1
- package/build/list/transforms.js.map +1 -1
- package/build/list-item/edit.js +3 -2
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/edit.native.js +3 -2
- package/build/list-item/edit.native.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +19 -22
- package/build/list-item/hooks/use-merge.js.map +1 -1
- package/build/list-item/hooks/use-outdent-list-item.js +19 -3
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/list-item/index.js +14 -1
- package/build/list-item/index.js.map +1 -1
- package/build/list-item/utils.js +14 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/navigation/edit/index.js +46 -33
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +3 -5
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +25 -8
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build/navigation/index.js +4 -1
- package/build/navigation/index.js.map +1 -1
- package/build/navigation-link/edit.js +1 -1
- package/build/navigation-link/edit.js.map +1 -1
- package/build/page-list/index.js +1 -5
- package/build/page-list/index.js.map +1 -1
- package/build/paragraph/deprecated.js +49 -10
- package/build/paragraph/deprecated.js.map +1 -1
- package/build/paragraph/edit.js +22 -14
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/save.js +3 -1
- package/build/paragraph/save.js.map +1 -1
- package/build/pattern/edit.js +11 -4
- package/build/pattern/edit.js.map +1 -1
- package/build/post-author/edit.js +20 -2
- package/build/post-author/edit.js.map +1 -1
- package/build/post-author/index.js +8 -0
- package/build/post-author/index.js.map +1 -1
- package/build/post-comments-form/form.js +1 -2
- package/build/post-comments-form/form.js.map +1 -1
- package/build/post-featured-image/index.js +1 -1
- package/build/post-featured-image/overlay.js +2 -2
- package/build/post-featured-image/overlay.js.map +1 -1
- package/build/post-terms/index.js +4 -0
- package/build/post-terms/index.js.map +1 -1
- package/build/query/edit/inspector-controls/author-control.js +2 -1
- package/build/query/edit/inspector-controls/author-control.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +3 -3
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/parent-control.js +2 -1
- package/build/query/edit/inspector-controls/parent-control.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +79 -103
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query/utils.js +1 -1
- package/build/query/utils.js.map +1 -1
- package/build/quote/index.js +0 -1
- package/build/quote/index.js.map +1 -1
- package/build/search/edit.js +2 -1
- package/build/search/edit.js.map +1 -1
- package/build/site-logo/edit.js +6 -9
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-title/index.js +2 -1
- package/build/site-title/index.js.map +1 -1
- package/build/table/state.js +1 -1
- package/build/table/state.js.map +1 -1
- package/build/table-of-contents/edit.js +1 -4
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/tag-cloud/edit.js +1 -1
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/tag-cloud/index.js +8 -0
- package/build/tag-cloud/index.js.map +1 -1
- package/build/template-part/index.js +2 -2
- package/build/template-part/index.js.map +1 -1
- package/build/video/edit.js +13 -1
- package/build/video/edit.js.map +1 -1
- package/build-module/archives/edit.js +1 -0
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/code/utils.js +3 -3
- package/build-module/code/utils.js.map +1 -1
- package/build-module/comment-template/edit.js +38 -30
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/comments/edit/placeholder.js +1 -3
- package/build-module/comments/edit/placeholder.js.map +1 -1
- package/build-module/comments/index.js +5 -1
- package/build-module/comments/index.js.map +1 -1
- package/build-module/comments-title/edit.js +18 -2
- package/build-module/comments-title/edit.js.map +1 -1
- package/build-module/cover/edit/index.js +2 -2
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/use-cover-is-dark.js +7 -7
- package/build-module/cover/edit/use-cover-is-dark.js.map +1 -1
- package/build-module/embed/variations.js +1 -1
- package/build-module/embed/variations.js.map +1 -1
- package/build-module/gallery/transforms.js +4 -4
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/gallery/v1/edit.js +2 -2
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/group/edit.js +1 -1
- package/build-module/group/edit.js.map +1 -1
- package/build-module/image/image.js +35 -11
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/transforms.js +1 -6
- package/build-module/image/transforms.js.map +1 -1
- package/build-module/list/transforms.js +9 -1
- package/build-module/list/transforms.js.map +1 -1
- package/build-module/list-item/edit.js +3 -2
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/edit.native.js +3 -2
- package/build-module/list-item/edit.native.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +19 -21
- package/build-module/list-item/hooks/use-merge.js.map +1 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js +19 -3
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/list-item/index.js +14 -1
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/list-item/utils.js +14 -1
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/navigation/edit/index.js +46 -33
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +3 -5
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +25 -8
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build-module/navigation/index.js +4 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation-link/edit.js +1 -1
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/page-list/index.js +1 -5
- package/build-module/page-list/index.js.map +1 -1
- package/build-module/paragraph/deprecated.js +49 -11
- package/build-module/paragraph/deprecated.js.map +1 -1
- package/build-module/paragraph/edit.js +22 -13
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/save.js +2 -1
- package/build-module/paragraph/save.js.map +1 -1
- package/build-module/pattern/edit.js +10 -3
- package/build-module/pattern/edit.js.map +1 -1
- package/build-module/post-author/edit.js +21 -2
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-author/index.js +8 -0
- package/build-module/post-author/index.js.map +1 -1
- package/build-module/post-comments-form/form.js +2 -3
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/post-featured-image/index.js +1 -1
- package/build-module/post-featured-image/overlay.js +2 -2
- package/build-module/post-featured-image/overlay.js.map +1 -1
- package/build-module/post-terms/index.js +4 -0
- package/build-module/post-terms/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/author-control.js +2 -1
- package/build-module/query/edit/inspector-controls/author-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +5 -5
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/parent-control.js +2 -1
- package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +81 -101
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query/utils.js +1 -1
- package/build-module/query/utils.js.map +1 -1
- package/build-module/quote/index.js +0 -1
- package/build-module/quote/index.js.map +1 -1
- package/build-module/search/edit.js +3 -2
- package/build-module/search/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +6 -9
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-title/index.js +2 -1
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/table/state.js +2 -2
- package/build-module/table/state.js.map +1 -1
- package/build-module/table-of-contents/edit.js +1 -3
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/tag-cloud/edit.js +1 -1
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/tag-cloud/index.js +8 -0
- package/build-module/tag-cloud/index.js.map +1 -1
- package/build-module/template-part/index.js +2 -2
- package/build-module/template-part/index.js.map +1 -1
- package/build-module/video/edit.js +15 -3
- package/build-module/video/edit.js.map +1 -1
- package/build-style/archives/style-rtl.css +4 -0
- package/build-style/archives/style.css +4 -0
- package/build-style/code/style-rtl.css +3 -0
- package/build-style/code/style.css +3 -0
- package/build-style/comments/editor-rtl.css +1 -0
- package/build-style/comments/editor.css +1 -0
- package/build-style/comments/style-rtl.css +1 -0
- package/build-style/comments/style.css +1 -0
- package/build-style/cover/editor-rtl.css +4 -0
- package/build-style/cover/editor.css +4 -0
- package/build-style/editor-rtl.css +78 -46
- package/build-style/editor.css +78 -46
- package/build-style/group/editor-rtl.css +1 -0
- package/build-style/group/editor.css +1 -0
- package/build-style/image/editor-rtl.css +1 -1
- package/build-style/image/editor.css +1 -1
- package/build-style/navigation/editor-rtl.css +5 -0
- package/build-style/navigation/editor.css +5 -0
- package/build-style/navigation/style-rtl.css +3 -0
- package/build-style/navigation/style.css +3 -0
- package/build-style/paragraph/editor-rtl.css +0 -16
- package/build-style/paragraph/editor.css +0 -16
- package/build-style/paragraph/style-rtl.css +5 -0
- package/build-style/paragraph/style.css +5 -0
- package/build-style/post-featured-image/editor-rtl.css +39 -29
- package/build-style/post-featured-image/editor.css +39 -29
- package/build-style/post-terms/style-rtl.css +4 -1
- package/build-style/post-terms/style.css +4 -1
- package/build-style/site-logo/editor-rtl.css +1 -0
- package/build-style/site-logo/editor.css +1 -0
- package/build-style/site-title/editor-rtl.css +4 -0
- package/build-style/site-title/editor.css +4 -0
- package/build-style/site-title/style-rtl.css +79 -0
- package/build-style/site-title/style.css +79 -0
- package/build-style/style-rtl.css +27 -1
- package/build-style/style.css +27 -1
- package/build-style/tag-cloud/style-rtl.css +3 -0
- package/build-style/tag-cloud/style.css +3 -0
- package/build-style/video/editor-rtl.css +22 -0
- package/build-style/video/editor.css +22 -0
- package/package.json +28 -28
- package/src/archives/edit.js +1 -0
- package/src/archives/style.scss +5 -0
- package/src/avatar/index.php +1 -1
- package/src/categories/index.php +1 -1
- package/src/code/style.scss +12 -7
- package/src/code/test/__snapshots__/edit.native.js.snap +13 -0
- package/src/code/test/edit.native.js +46 -32
- package/src/code/utils.js +3 -3
- package/src/comment-author-name/index.php +1 -1
- package/src/comment-reply-link/index.php +1 -1
- package/src/comment-template/edit.js +47 -34
- package/src/comment-template/index.php +2 -3
- package/src/comments/block.json +5 -1
- package/src/comments/edit/placeholder.js +1 -7
- package/src/comments/style.scss +2 -0
- package/src/comments-title/edit.js +24 -1
- package/src/cover/edit/index.js +2 -7
- package/src/cover/edit/use-cover-is-dark.js +11 -11
- package/src/cover/editor.scss +7 -0
- package/src/cover/index.php +1 -1
- package/src/embed/variations.js +1 -1
- package/src/gallery/transforms.js +8 -5
- package/src/gallery/v1/edit.js +2 -2
- package/src/group/edit.js +1 -1
- package/src/group/editor.scss +1 -0
- package/src/image/editor.scss +4 -1
- package/src/image/image.js +59 -29
- package/src/image/transforms.js +1 -7
- package/src/latest-posts/index.php +1 -1
- package/src/list/test/edit.native.js +102 -3
- package/src/list/transforms.js +11 -0
- package/src/list-item/block.json +14 -1
- package/src/list-item/edit.js +2 -1
- package/src/list-item/edit.native.js +2 -1
- package/src/list-item/hooks/use-merge.js +4 -23
- package/src/list-item/hooks/use-outdent-list-item.js +6 -2
- package/src/navigation/block.json +4 -1
- package/src/navigation/edit/index.js +60 -32
- package/src/navigation/edit/inner-blocks.js +2 -5
- package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +32 -5
- package/src/navigation/edit/use-create-navigation-menu.js +2 -5
- package/src/navigation/editor.scss +7 -0
- package/src/navigation/index.php +103 -6
- package/src/navigation/style.scss +8 -0
- package/src/navigation-link/edit.js +1 -1
- package/src/navigation-link/index.php +8 -1
- package/src/navigation-submenu/index.php +8 -1
- package/src/page-list/block.json +1 -5
- package/src/page-list/index.php +10 -8
- package/src/paragraph/deprecated.js +36 -0
- package/src/paragraph/edit.js +24 -22
- package/src/paragraph/editor.scss +0 -20
- package/src/paragraph/save.js +5 -1
- package/src/paragraph/style.scss +5 -0
- package/src/pattern/edit.js +10 -3
- package/src/post-author/block.json +8 -0
- package/src/post-author/edit.js +29 -3
- package/src/post-author/index.php +7 -1
- package/src/post-comments-form/form.js +2 -3
- package/src/post-featured-image/block.json +1 -1
- package/src/post-featured-image/editor.scss +79 -72
- package/src/post-featured-image/index.php +18 -24
- package/src/post-featured-image/overlay.js +17 -14
- package/src/post-terms/block.json +4 -0
- package/src/post-terms/style.scss +7 -2
- package/src/query/edit/inspector-controls/author-control.js +1 -0
- package/src/query/edit/inspector-controls/index.js +5 -7
- package/src/query/edit/inspector-controls/parent-control.js +1 -0
- package/src/query/edit/inspector-controls/taxonomy-controls.js +82 -86
- package/src/query/utils.js +1 -1
- package/src/quote/block.json +0 -1
- package/src/rss/index.php +3 -3
- package/src/search/edit.js +6 -1
- package/src/search/index.php +21 -13
- package/src/site-logo/edit.js +10 -8
- package/src/site-logo/editor.scss +1 -0
- package/src/site-title/block.json +2 -1
- package/src/site-title/editor.scss +6 -0
- package/src/site-title/style.scss +5 -0
- package/src/style.scss +1 -0
- package/src/table/state.js +2 -2
- package/src/table-of-contents/edit.js +1 -3
- package/src/tag-cloud/block.json +8 -0
- package/src/tag-cloud/edit.js +1 -1
- package/src/tag-cloud/style.scss +3 -0
- package/src/template-part/index.js +2 -2
- package/src/template-part/index.php +4 -0
- package/src/video/edit.js +19 -0
- package/src/video/editor.scss +37 -0
- package/build/navigation-submenu/view.js +0 -56
- package/build/navigation-submenu/view.js.map +0 -1
- package/build/paragraph/drop-zone.js +0 -99
- package/build/paragraph/drop-zone.js.map +0 -1
- package/build-module/navigation-submenu/view.js +0 -54
- package/build-module/navigation-submenu/view.js.map +0 -1
- package/build-module/paragraph/drop-zone.js +0 -88
- package/build-module/paragraph/drop-zone.js.map +0 -1
- package/src/navigation-submenu/view.js +0 -67
- package/src/paragraph/drop-zone.js +0 -105
package/src/cover/index.php
CHANGED
|
@@ -25,7 +25,7 @@ function render_block_core_cover( $attributes, $content ) {
|
|
|
25
25
|
);
|
|
26
26
|
|
|
27
27
|
if ( isset( $attributes['focalPoint'] ) ) {
|
|
28
|
-
$object_position = round( $attributes['focalPoint']['x'] * 100 ) . '%
|
|
28
|
+
$object_position = round( $attributes['focalPoint']['x'] * 100 ) . '% ' . round( $attributes['focalPoint']['y'] * 100 ) . '%';
|
|
29
29
|
$attr['data-object-position'] = $object_position;
|
|
30
30
|
$attr['style'] = 'object-position: ' . $object_position;
|
|
31
31
|
}
|
package/src/embed/variations.js
CHANGED
|
@@ -309,7 +309,7 @@ const variations = [
|
|
|
309
309
|
icon: embedTumblrIcon,
|
|
310
310
|
keywords: [ __( 'social' ) ],
|
|
311
311
|
description: __( 'Embed a Tumblr post.' ),
|
|
312
|
-
patterns: [ /^https?:\/\/(
|
|
312
|
+
patterns: [ /^https?:\/\/(.+)\.tumblr\.com\/.+/i ],
|
|
313
313
|
attributes: { providerNameSlug: 'tumblr', responsive: true },
|
|
314
314
|
},
|
|
315
315
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { filter
|
|
4
|
+
import { filter } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -133,10 +133,14 @@ const transforms = {
|
|
|
133
133
|
// Init the align and size from the first item which may be either the placeholder or an image.
|
|
134
134
|
let { align, sizeSlug } = attributes[ 0 ];
|
|
135
135
|
// Loop through all the images and check if they have the same align and size.
|
|
136
|
-
align = every(
|
|
136
|
+
align = attributes.every(
|
|
137
|
+
( attribute ) => attribute.align === align
|
|
138
|
+
)
|
|
137
139
|
? align
|
|
138
140
|
: undefined;
|
|
139
|
-
sizeSlug = every(
|
|
141
|
+
sizeSlug = attributes.every(
|
|
142
|
+
( attribute ) => attribute.sizeSlug === sizeSlug
|
|
143
|
+
)
|
|
140
144
|
? sizeSlug
|
|
141
145
|
: undefined;
|
|
142
146
|
|
|
@@ -268,8 +272,7 @@ const transforms = {
|
|
|
268
272
|
isMatch( files ) {
|
|
269
273
|
return (
|
|
270
274
|
files.length !== 1 &&
|
|
271
|
-
every(
|
|
272
|
-
files,
|
|
275
|
+
files.every(
|
|
273
276
|
( file ) => file.type.indexOf( 'image/' ) === 0
|
|
274
277
|
)
|
|
275
278
|
);
|
package/src/gallery/v1/edit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { filter, find, get, isEmpty, map, reduce, some } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -333,7 +333,7 @@ function GalleryEdit( props ) {
|
|
|
333
333
|
Platform.OS === 'web' &&
|
|
334
334
|
images &&
|
|
335
335
|
images.length > 0 &&
|
|
336
|
-
every(
|
|
336
|
+
images.every( ( { url } ) => isBlobURL( url ) )
|
|
337
337
|
) {
|
|
338
338
|
const filesList = map( images, ( { url } ) => getBlobByURL( url ) );
|
|
339
339
|
images.forEach( ( { url } ) => revokeBlobURL( url ) );
|
package/src/group/edit.js
CHANGED
|
@@ -53,7 +53,7 @@ function GroupEdit( { attributes, setAttributes, clientId } ) {
|
|
|
53
53
|
? { ...defaultLayout, ...layout, type: 'default' }
|
|
54
54
|
: { ...defaultLayout, ...layout };
|
|
55
55
|
const { type = 'default' } = usedLayout;
|
|
56
|
-
const layoutSupportEnabled = themeSupportsLayout || type
|
|
56
|
+
const layoutSupportEnabled = themeSupportsLayout || type === 'flex';
|
|
57
57
|
|
|
58
58
|
const blockProps = useBlockProps();
|
|
59
59
|
|
package/src/group/editor.scss
CHANGED
package/src/image/editor.scss
CHANGED
|
@@ -66,7 +66,10 @@ figure.wp-block-image:not(.wp-block) {
|
|
|
66
66
|
|
|
67
67
|
// This is necessary for the editor resize handles to accurately work on a non-floated, non-resized, small image.
|
|
68
68
|
.wp-block-image .components-resizable-box__container {
|
|
69
|
-
display:
|
|
69
|
+
// Using "display: table" because:
|
|
70
|
+
// - it visually hides empty white space in between elements
|
|
71
|
+
// - it allows the element to be as wide as its contents (instead of 100% width, as it would be with `display: block`)
|
|
72
|
+
display: table;
|
|
70
73
|
img {
|
|
71
74
|
display: block;
|
|
72
75
|
width: inherit;
|
package/src/image/image.js
CHANGED
|
@@ -40,7 +40,12 @@ import {
|
|
|
40
40
|
getDefaultBlockName,
|
|
41
41
|
switchToBlockType,
|
|
42
42
|
} from '@wordpress/blocks';
|
|
43
|
-
import {
|
|
43
|
+
import {
|
|
44
|
+
crop,
|
|
45
|
+
overlayText,
|
|
46
|
+
upload,
|
|
47
|
+
caption as captionIcon,
|
|
48
|
+
} from '@wordpress/icons';
|
|
44
49
|
import { store as noticesStore } from '@wordpress/notices';
|
|
45
50
|
import { store as coreStore } from '@wordpress/core-data';
|
|
46
51
|
|
|
@@ -89,7 +94,8 @@ export default function Image( {
|
|
|
89
94
|
} = attributes;
|
|
90
95
|
const imageRef = useRef();
|
|
91
96
|
const captionRef = useRef();
|
|
92
|
-
const
|
|
97
|
+
const prevCaption = usePrevious( caption );
|
|
98
|
+
const [ showCaption, setShowCaption ] = useState( !! caption );
|
|
93
99
|
const { allowResize = true } = context;
|
|
94
100
|
const { getBlock } = useSelect( blockEditorStore );
|
|
95
101
|
|
|
@@ -180,15 +186,20 @@ export default function Image( {
|
|
|
180
186
|
.catch( () => {} );
|
|
181
187
|
}, [ id, url, isSelected, externalBlob ] );
|
|
182
188
|
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
|
|
186
|
-
|
|
189
|
+
// We need to show the caption when changes come from
|
|
190
|
+
// history navigation(undo/redo).
|
|
191
|
+
useEffect( () => {
|
|
192
|
+
if ( caption && ! prevCaption ) {
|
|
193
|
+
setShowCaption( true );
|
|
194
|
+
}
|
|
195
|
+
}, [ caption, prevCaption ] );
|
|
196
|
+
|
|
197
|
+
// Focus the caption when we click to add one.
|
|
187
198
|
useEffect( () => {
|
|
188
|
-
if (
|
|
189
|
-
captionRef.current
|
|
199
|
+
if ( showCaption && ! caption ) {
|
|
200
|
+
captionRef.current?.focus();
|
|
190
201
|
}
|
|
191
|
-
}, [
|
|
202
|
+
}, [ caption, showCaption ] );
|
|
192
203
|
|
|
193
204
|
// Get naturalWidth and naturalHeight from image ref, and fall back to loaded natural
|
|
194
205
|
// width and height. This resolves an issue in Safari where the loaded natural
|
|
@@ -297,8 +308,11 @@ export default function Image( {
|
|
|
297
308
|
useEffect( () => {
|
|
298
309
|
if ( ! isSelected ) {
|
|
299
310
|
setIsEditingImage( false );
|
|
311
|
+
if ( ! caption ) {
|
|
312
|
+
setShowCaption( false );
|
|
313
|
+
}
|
|
300
314
|
}
|
|
301
|
-
}, [ isSelected ] );
|
|
315
|
+
}, [ isSelected, caption ] );
|
|
302
316
|
|
|
303
317
|
const canEditImage = id && naturalWidth && naturalHeight && imageEditing;
|
|
304
318
|
const allowCrop = ! multiImageSelection && canEditImage && ! isEditingImage;
|
|
@@ -319,6 +333,19 @@ export default function Image( {
|
|
|
319
333
|
onChange={ updateAlignment }
|
|
320
334
|
/>
|
|
321
335
|
) }
|
|
336
|
+
{ ! isContentLocked && (
|
|
337
|
+
<ToolbarButton
|
|
338
|
+
onClick={ () => {
|
|
339
|
+
setShowCaption( ! showCaption );
|
|
340
|
+
if ( showCaption && caption ) {
|
|
341
|
+
setAttributes( { caption: undefined } );
|
|
342
|
+
}
|
|
343
|
+
} }
|
|
344
|
+
icon={ captionIcon }
|
|
345
|
+
isPressed={ showCaption }
|
|
346
|
+
label={ __( 'Caption' ) }
|
|
347
|
+
/>
|
|
348
|
+
) }
|
|
322
349
|
{ ! multiImageSelection && ! isEditingImage && (
|
|
323
350
|
<ImageURLInputUI
|
|
324
351
|
url={ href || '' }
|
|
@@ -591,25 +618,28 @@ export default function Image( {
|
|
|
591
618
|
which causes duplicated image upload. */ }
|
|
592
619
|
{ ! temporaryURL && controls }
|
|
593
620
|
{ img }
|
|
594
|
-
{
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
)
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
621
|
+
{ showCaption &&
|
|
622
|
+
( ! RichText.isEmpty( caption ) || isSelected ) && (
|
|
623
|
+
<RichText
|
|
624
|
+
className={ __experimentalGetElementClassName(
|
|
625
|
+
'caption'
|
|
626
|
+
) }
|
|
627
|
+
ref={ captionRef }
|
|
628
|
+
tagName="figcaption"
|
|
629
|
+
aria-label={ __( 'Image caption text' ) }
|
|
630
|
+
placeholder={ __( 'Add caption' ) }
|
|
631
|
+
value={ caption }
|
|
632
|
+
onChange={ ( value ) =>
|
|
633
|
+
setAttributes( { caption: value } )
|
|
634
|
+
}
|
|
635
|
+
inlineToolbar
|
|
636
|
+
__unstableOnSplitAtEnd={ () =>
|
|
637
|
+
insertBlocksAfter(
|
|
638
|
+
createBlock( getDefaultBlockName() )
|
|
639
|
+
)
|
|
640
|
+
}
|
|
641
|
+
/>
|
|
642
|
+
) }
|
|
613
643
|
</ImageEditingProvider>
|
|
614
644
|
);
|
|
615
645
|
}
|
package/src/image/transforms.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { every } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -157,8 +152,7 @@ const transforms = {
|
|
|
157
152
|
}
|
|
158
153
|
);
|
|
159
154
|
}
|
|
160
|
-
return every(
|
|
161
|
-
files,
|
|
155
|
+
return files.every(
|
|
162
156
|
( file ) => file.type.indexOf( 'image/' ) === 0
|
|
163
157
|
);
|
|
164
158
|
},
|
|
@@ -55,7 +55,7 @@ function render_block_core_latest_posts( $attributes ) {
|
|
|
55
55
|
$args['author'] = $attributes['selectedAuthor'];
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
$query = new WP_Query;
|
|
58
|
+
$query = new WP_Query();
|
|
59
59
|
$recent_posts = $query->query( $args );
|
|
60
60
|
|
|
61
61
|
if ( isset( $attributes['displayFeaturedImage'] ) && $attributes['displayFeaturedImage'] ) {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
5
|
changeTextOfRichText,
|
|
6
|
+
changeAndSelectTextOfRichText,
|
|
6
7
|
fireEvent,
|
|
7
8
|
getEditorHtml,
|
|
8
9
|
initializeEditor,
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
*/
|
|
19
20
|
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
|
|
20
21
|
import { registerCoreBlocks } from '@wordpress/block-library';
|
|
22
|
+
import { BACKSPACE } from '@wordpress/keycodes';
|
|
21
23
|
|
|
22
24
|
describe( 'List block', () => {
|
|
23
25
|
beforeAll( () => {
|
|
@@ -210,7 +212,7 @@ describe( 'List block', () => {
|
|
|
210
212
|
<!-- /wp:list-item -->
|
|
211
213
|
<!-- wp:list-item -->
|
|
212
214
|
<li>Item 2</li>
|
|
213
|
-
<!-- /wp:list-item -->
|
|
215
|
+
<!-- /wp:list-item -->
|
|
214
216
|
<!-- wp:list-item -->
|
|
215
217
|
<li>Item 3</li>
|
|
216
218
|
<!-- /wp:list-item --></ul>
|
|
@@ -238,7 +240,7 @@ describe( 'List block', () => {
|
|
|
238
240
|
<!-- /wp:list-item -->
|
|
239
241
|
<!-- wp:list-item -->
|
|
240
242
|
<li>Item 2</li>
|
|
241
|
-
<!-- /wp:list-item -->
|
|
243
|
+
<!-- /wp:list-item -->
|
|
242
244
|
<!-- wp:list-item -->
|
|
243
245
|
<li>Item 3</li>
|
|
244
246
|
<!-- /wp:list-item --></ul>
|
|
@@ -277,7 +279,7 @@ describe( 'List block', () => {
|
|
|
277
279
|
<!-- /wp:list-item -->
|
|
278
280
|
<!-- wp:list-item -->
|
|
279
281
|
<li>Item 2</li>
|
|
280
|
-
<!-- /wp:list-item -->
|
|
282
|
+
<!-- /wp:list-item -->
|
|
281
283
|
<!-- wp:list-item -->
|
|
282
284
|
<li>Item 3</li>
|
|
283
285
|
<!-- /wp:list-item --></ul>
|
|
@@ -311,4 +313,101 @@ describe( 'List block', () => {
|
|
|
311
313
|
|
|
312
314
|
expect( getEditorHtml() ).toMatchSnapshot();
|
|
313
315
|
} );
|
|
316
|
+
|
|
317
|
+
it( 'merges with other lists', async () => {
|
|
318
|
+
const initialHtml = `<!-- wp:list -->
|
|
319
|
+
<ul><!-- wp:list-item -->
|
|
320
|
+
<li>One</li><!-- /wp:list-item --></ul>
|
|
321
|
+
<!-- /wp:list --><!-- wp:list -->
|
|
322
|
+
<ul><!-- wp:list-item -->
|
|
323
|
+
<li>Two</li><!-- /wp:list-item --></ul>
|
|
324
|
+
<!-- /wp:list -->`;
|
|
325
|
+
|
|
326
|
+
const screen = await initializeEditor( {
|
|
327
|
+
initialHtml,
|
|
328
|
+
} );
|
|
329
|
+
|
|
330
|
+
// Select List block
|
|
331
|
+
const listBlock = screen.getByA11yLabel( /List Block\. Row 2/ );
|
|
332
|
+
fireEvent.press( listBlock );
|
|
333
|
+
|
|
334
|
+
// Select List Item block
|
|
335
|
+
const listItemBlock = within( listBlock ).getByA11yLabel(
|
|
336
|
+
/List item Block\. Row 1/
|
|
337
|
+
);
|
|
338
|
+
fireEvent.press( listItemBlock );
|
|
339
|
+
|
|
340
|
+
// With cursor positioned at the beginning of the first List Item, press
|
|
341
|
+
// backward delete
|
|
342
|
+
const listItemField =
|
|
343
|
+
within( listItemBlock ).getByA11yLabel( /Text input. .*Two.*/ );
|
|
344
|
+
changeAndSelectTextOfRichText( listItemField, 'Two' );
|
|
345
|
+
fireEvent( listItemField, 'onKeyDown', {
|
|
346
|
+
nativeEvent: {},
|
|
347
|
+
preventDefault() {},
|
|
348
|
+
keyCode: BACKSPACE,
|
|
349
|
+
} );
|
|
350
|
+
|
|
351
|
+
expect( getEditorHtml() ).toMatchInlineSnapshot( `
|
|
352
|
+
"<!-- wp:list -->
|
|
353
|
+
<ul><!-- wp:list-item -->
|
|
354
|
+
<li>One</li>
|
|
355
|
+
<!-- /wp:list-item -->
|
|
356
|
+
|
|
357
|
+
<!-- wp:list-item -->
|
|
358
|
+
<li>Two</li>
|
|
359
|
+
<!-- /wp:list-item --></ul>
|
|
360
|
+
<!-- /wp:list -->"
|
|
361
|
+
` );
|
|
362
|
+
} );
|
|
363
|
+
|
|
364
|
+
it( 'unwraps list items when attempting to merge with non-list block', async () => {
|
|
365
|
+
const initialHtml = `<!-- wp:paragraph -->
|
|
366
|
+
<p>A quick brown fox.</p>
|
|
367
|
+
<!-- /wp:paragraph -->
|
|
368
|
+
<!-- wp:list -->
|
|
369
|
+
<ul><!-- wp:list-item -->
|
|
370
|
+
<li>One</li><!-- /wp:list-item --><!-- wp:list-item -->
|
|
371
|
+
<li>Two</li><!-- /wp:list-item --></ul>
|
|
372
|
+
<!-- /wp:list -->`;
|
|
373
|
+
|
|
374
|
+
const screen = await initializeEditor( {
|
|
375
|
+
initialHtml,
|
|
376
|
+
} );
|
|
377
|
+
|
|
378
|
+
// Select List block
|
|
379
|
+
const listBlock = screen.getByA11yLabel( /List Block\. Row 2/ );
|
|
380
|
+
fireEvent.press( listBlock );
|
|
381
|
+
|
|
382
|
+
// Select List Item block
|
|
383
|
+
const listItemBlock = within( listBlock ).getByA11yLabel(
|
|
384
|
+
/List item Block\. Row 1/
|
|
385
|
+
);
|
|
386
|
+
fireEvent.press( listItemBlock );
|
|
387
|
+
|
|
388
|
+
// With cursor positioned at the beginning of the first List Item, press
|
|
389
|
+
// backward delete
|
|
390
|
+
const listItemField =
|
|
391
|
+
within( listItemBlock ).getByA11yLabel( /Text input. .*One.*/ );
|
|
392
|
+
changeAndSelectTextOfRichText( listItemField, 'One' );
|
|
393
|
+
fireEvent( listItemField, 'onKeyDown', {
|
|
394
|
+
nativeEvent: {},
|
|
395
|
+
preventDefault() {},
|
|
396
|
+
keyCode: BACKSPACE,
|
|
397
|
+
} );
|
|
398
|
+
|
|
399
|
+
expect( getEditorHtml() ).toMatchInlineSnapshot( `
|
|
400
|
+
"<!-- wp:paragraph -->
|
|
401
|
+
<p>A quick brown fox.</p>
|
|
402
|
+
<!-- /wp:paragraph -->
|
|
403
|
+
|
|
404
|
+
<!-- wp:paragraph -->
|
|
405
|
+
<p>One</p>
|
|
406
|
+
<!-- /wp:paragraph -->
|
|
407
|
+
|
|
408
|
+
<!-- wp:paragraph -->
|
|
409
|
+
<p>Two</p>
|
|
410
|
+
<!-- /wp:paragraph -->"
|
|
411
|
+
` );
|
|
412
|
+
} );
|
|
314
413
|
} );
|
package/src/list/transforms.js
CHANGED
|
@@ -114,6 +114,17 @@ const transforms = {
|
|
|
114
114
|
);
|
|
115
115
|
},
|
|
116
116
|
} ) ),
|
|
117
|
+
{
|
|
118
|
+
type: 'block',
|
|
119
|
+
blocks: [ '*' ],
|
|
120
|
+
transform: ( _attributes, childBlocks ) => {
|
|
121
|
+
return getListContentFlat( childBlocks ).map( ( content ) =>
|
|
122
|
+
createBlock( 'core/paragraph', {
|
|
123
|
+
content,
|
|
124
|
+
} )
|
|
125
|
+
);
|
|
126
|
+
},
|
|
127
|
+
},
|
|
117
128
|
],
|
|
118
129
|
};
|
|
119
130
|
|
package/src/list-item/block.json
CHANGED
|
@@ -21,6 +21,19 @@
|
|
|
21
21
|
},
|
|
22
22
|
"supports": {
|
|
23
23
|
"className": false,
|
|
24
|
-
"__experimentalSelector": "li"
|
|
24
|
+
"__experimentalSelector": "li",
|
|
25
|
+
"typography": {
|
|
26
|
+
"fontSize": true,
|
|
27
|
+
"lineHeight": true,
|
|
28
|
+
"__experimentalFontFamily": true,
|
|
29
|
+
"__experimentalFontWeight": true,
|
|
30
|
+
"__experimentalFontStyle": true,
|
|
31
|
+
"__experimentalTextTransform": true,
|
|
32
|
+
"__experimentalTextDecoration": true,
|
|
33
|
+
"__experimentalLetterSpacing": true,
|
|
34
|
+
"__experimentalDefaultControls": {
|
|
35
|
+
"fontSize": true
|
|
36
|
+
}
|
|
37
|
+
}
|
|
25
38
|
}
|
|
26
39
|
}
|
package/src/list-item/edit.js
CHANGED
|
@@ -60,6 +60,7 @@ export default function ListItemEdit( {
|
|
|
60
60
|
setAttributes,
|
|
61
61
|
onReplace,
|
|
62
62
|
clientId,
|
|
63
|
+
mergeBlocks,
|
|
63
64
|
} ) {
|
|
64
65
|
const { placeholder, content } = attributes;
|
|
65
66
|
const blockProps = useBlockProps( { ref: useCopy( clientId ) } );
|
|
@@ -70,7 +71,7 @@ export default function ListItemEdit( {
|
|
|
70
71
|
const useEnterRef = useEnter( { content, clientId } );
|
|
71
72
|
const useSpaceRef = useSpace( clientId );
|
|
72
73
|
const onSplit = useSplit( clientId );
|
|
73
|
-
const onMerge = useMerge( clientId );
|
|
74
|
+
const onMerge = useMerge( clientId, mergeBlocks );
|
|
74
75
|
return (
|
|
75
76
|
<>
|
|
76
77
|
<li { ...innerBlocksProps }>
|
|
@@ -35,6 +35,7 @@ export default function ListItemEdit( {
|
|
|
35
35
|
onReplace,
|
|
36
36
|
clientId,
|
|
37
37
|
style,
|
|
38
|
+
mergeBlocks,
|
|
38
39
|
} ) {
|
|
39
40
|
const [ contentWidth, setContentWidth ] = useState();
|
|
40
41
|
const { placeholder, content } = attributes;
|
|
@@ -119,7 +120,7 @@ export default function ListItemEdit( {
|
|
|
119
120
|
const preventDefault = useRef( false );
|
|
120
121
|
const { onEnter } = useEnter( { content, clientId }, preventDefault );
|
|
121
122
|
const onSplit = useSplit( clientId );
|
|
122
|
-
const onMerge = useMerge( clientId );
|
|
123
|
+
const onMerge = useMerge( clientId, mergeBlocks );
|
|
123
124
|
const onSplitList = useCallback(
|
|
124
125
|
( value ) => {
|
|
125
126
|
if ( ! preventDefault.current ) {
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useRegistry, useDispatch, useSelect } from '@wordpress/data';
|
|
5
5
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
6
|
-
import { getDefaultBlockName, switchToBlockType } from '@wordpress/blocks';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Internal dependencies
|
|
@@ -12,7 +11,7 @@ import useOutdentListItem from './use-outdent-list-item';
|
|
|
12
11
|
|
|
13
12
|
import { name as listItemName } from '../block.json';
|
|
14
13
|
|
|
15
|
-
export default function useMerge( clientId ) {
|
|
14
|
+
export default function useMerge( clientId, onMerge ) {
|
|
16
15
|
const registry = useRegistry();
|
|
17
16
|
const {
|
|
18
17
|
getPreviousBlockClientId,
|
|
@@ -20,9 +19,8 @@ export default function useMerge( clientId ) {
|
|
|
20
19
|
getBlockOrder,
|
|
21
20
|
getBlockRootClientId,
|
|
22
21
|
getBlockName,
|
|
23
|
-
getBlock,
|
|
24
22
|
} = useSelect( blockEditorStore );
|
|
25
|
-
const { mergeBlocks, moveBlocksToPosition
|
|
23
|
+
const { mergeBlocks, moveBlocksToPosition } =
|
|
26
24
|
useDispatch( blockEditorStore );
|
|
27
25
|
const [ , outdentListItem ] = useOutdentListItem( clientId );
|
|
28
26
|
|
|
@@ -79,29 +77,12 @@ export default function useMerge( clientId ) {
|
|
|
79
77
|
return getBlockOrder( order[ 0 ] )[ 0 ];
|
|
80
78
|
}
|
|
81
79
|
|
|
82
|
-
function switchToDefaultBlockType( forward ) {
|
|
83
|
-
const rootClientId = getBlockRootClientId( clientId );
|
|
84
|
-
const replacement = switchToBlockType(
|
|
85
|
-
getBlock( rootClientId ),
|
|
86
|
-
getDefaultBlockName()
|
|
87
|
-
);
|
|
88
|
-
const indexToSelect = forward ? replacement.length - 1 : 0;
|
|
89
|
-
const initialPosition = forward ? -1 : 0;
|
|
90
|
-
registry.batch( () => {
|
|
91
|
-
replaceBlock( rootClientId, replacement );
|
|
92
|
-
selectBlock(
|
|
93
|
-
replacement[ indexToSelect ].clientId,
|
|
94
|
-
initialPosition
|
|
95
|
-
);
|
|
96
|
-
} );
|
|
97
|
-
}
|
|
98
|
-
|
|
99
80
|
return ( forward ) => {
|
|
100
81
|
if ( forward ) {
|
|
101
82
|
const nextBlockClientId = getNextId( clientId );
|
|
102
83
|
|
|
103
84
|
if ( ! nextBlockClientId ) {
|
|
104
|
-
|
|
85
|
+
onMerge( forward );
|
|
105
86
|
return;
|
|
106
87
|
}
|
|
107
88
|
|
|
@@ -134,7 +115,7 @@ export default function useMerge( clientId ) {
|
|
|
134
115
|
mergeBlocks( trailingId, clientId );
|
|
135
116
|
} );
|
|
136
117
|
} else {
|
|
137
|
-
|
|
118
|
+
onMerge( forward );
|
|
138
119
|
}
|
|
139
120
|
}
|
|
140
121
|
};
|
|
@@ -20,12 +20,16 @@ export default function useOutdentListItem( clientId ) {
|
|
|
20
20
|
const registry = useRegistry();
|
|
21
21
|
const { canOutdent } = useSelect(
|
|
22
22
|
( innerSelect ) => {
|
|
23
|
-
const { getBlockRootClientId } =
|
|
23
|
+
const { getBlockRootClientId, getBlockName } =
|
|
24
|
+
innerSelect( blockEditorStore );
|
|
24
25
|
const grandParentId = getBlockRootClientId(
|
|
25
26
|
getBlockRootClientId( clientId )
|
|
26
27
|
);
|
|
28
|
+
const grandParentName = getBlockName( grandParentId );
|
|
29
|
+
const isListItem = grandParentName === listItemName;
|
|
30
|
+
|
|
27
31
|
return {
|
|
28
|
-
canOutdent:
|
|
32
|
+
canOutdent: isListItem,
|
|
29
33
|
};
|
|
30
34
|
},
|
|
31
35
|
[ clientId ]
|
|
@@ -67,6 +67,10 @@
|
|
|
67
67
|
"maxNestingLevel": {
|
|
68
68
|
"type": "number",
|
|
69
69
|
"default": 5
|
|
70
|
+
},
|
|
71
|
+
"templateLock": {
|
|
72
|
+
"type": [ "string", "boolean" ],
|
|
73
|
+
"enum": [ "all", "insert", "contentOnly", false ]
|
|
70
74
|
}
|
|
71
75
|
},
|
|
72
76
|
"providesContext": {
|
|
@@ -88,7 +92,6 @@
|
|
|
88
92
|
},
|
|
89
93
|
"supports": {
|
|
90
94
|
"align": [ "wide", "full" ],
|
|
91
|
-
"anchor": true,
|
|
92
95
|
"html": false,
|
|
93
96
|
"inserter": true,
|
|
94
97
|
"typography": {
|