@wordpress/block-library 7.1.1 → 7.2.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 +11 -0
- package/build/avatar/edit.js +205 -0
- package/build/avatar/edit.js.map +1 -0
- package/build/avatar/hooks.js +111 -0
- package/build/avatar/hooks.js.map +1 -0
- package/build/avatar/index.js +83 -0
- package/build/avatar/index.js.map +1 -0
- package/build/avatar/user-control.js +63 -0
- package/build/avatar/user-control.js.map +1 -0
- package/build/column/index.js +2 -1
- package/build/column/index.js.map +1 -1
- package/build/comment-author-avatar/index.js +1 -0
- package/build/comment-author-avatar/index.js.map +1 -1
- package/build/comment-date/edit.js +10 -25
- package/build/comment-date/edit.js.map +1 -1
- package/build/comment-template/edit.js +79 -52
- package/build/comment-template/edit.js.map +1 -1
- package/build/cover/edit.js +23 -33
- package/build/cover/edit.js.map +1 -1
- package/build/embed/variations.js +2 -2
- package/build/embed/variations.js.map +1 -1
- package/build/gallery/edit.js +18 -5
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.js +1 -1
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/gap-styles.js +29 -0
- package/build/gallery/gap-styles.js.map +1 -0
- package/build/gallery/index.js +17 -1
- package/build/gallery/index.js.map +1 -1
- package/build/group/index.js +3 -1
- package/build/group/index.js.map +1 -1
- package/build/group/variations.js +1 -2
- package/build/group/variations.js.map +1 -1
- package/build/image/image.js +3 -1
- package/build/image/image.js.map +1 -1
- package/build/index.js +8 -2
- package/build/index.js.map +1 -1
- package/build/list/index.js +5 -7
- package/build/list/index.js.map +1 -1
- package/build/list/v2/edit.js +85 -0
- package/build/list/v2/edit.js.map +1 -0
- package/build/list/v2/index.js +33 -0
- package/build/list/v2/index.js.map +1 -0
- package/build/list/v2/save.js +34 -0
- package/build/list/v2/save.js.map +1 -0
- package/build/list/v2/transforms.js +121 -0
- package/build/list/v2/transforms.js.map +1 -0
- package/build/list-item/edit.js +47 -0
- package/build/list-item/edit.js.map +1 -0
- package/build/list-item/index.js +67 -0
- package/build/list-item/index.js.map +1 -0
- package/build/list-item/save.js +23 -0
- package/build/list-item/save.js.map +1 -0
- package/build/media-text/edit.js +3 -1
- package/build/media-text/edit.js.map +1 -1
- package/build/navigation/use-navigation-entities.js +26 -54
- package/build/navigation/use-navigation-entities.js.map +1 -1
- package/build/navigation-link/edit.js +88 -34
- package/build/navigation-link/edit.js.map +1 -1
- package/build/post-date/edit.js +31 -37
- package/build/post-date/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +2 -1
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/pullquote/edit.js +5 -3
- package/build/pullquote/edit.js.map +1 -1
- package/build/query/variations.js +4 -4
- package/build/query/variations.js.map +1 -1
- package/build/query-no-results/edit.js +28 -0
- package/build/query-no-results/edit.js.map +1 -0
- package/build/query-no-results/index.js +54 -0
- package/build/query-no-results/index.js.map +1 -0
- package/build/query-no-results/save.js +18 -0
- package/build/query-no-results/save.js.map +1 -0
- package/build/search/edit.js +2 -3
- package/build/search/edit.js.map +1 -1
- package/build/separator/deprecated.js +83 -0
- package/build/separator/deprecated.js.map +1 -0
- package/build/separator/edit.js +31 -23
- package/build/separator/edit.js.map +1 -1
- package/build/separator/index.js +17 -7
- package/build/separator/index.js.map +1 -1
- package/build/separator/save.js +18 -13
- package/build/separator/save.js.map +1 -1
- package/build/separator/use-deprecated-opacity.js +39 -0
- package/build/separator/use-deprecated-opacity.js.map +1 -0
- package/build/social-links/edit.js +14 -3
- package/build/social-links/edit.js.map +1 -1
- package/build/social-links/index.js +1 -1
- package/build/spacer/controls.js +6 -16
- package/build/spacer/controls.js.map +1 -1
- package/build/spacer/controls.native.js +3 -1
- package/build/spacer/controls.native.js.map +1 -1
- package/build/spacer/edit.js +4 -5
- package/build/spacer/edit.js.map +1 -1
- package/build/table/deprecated.js +1 -1
- package/build/table/deprecated.js.map +1 -1
- package/build/tag-cloud/edit.js +58 -2
- 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-module/avatar/edit.js +190 -0
- package/build-module/avatar/edit.js.map +1 -0
- package/build-module/avatar/hooks.js +99 -0
- package/build-module/avatar/hooks.js.map +1 -0
- package/build-module/avatar/index.js +70 -0
- package/build-module/avatar/index.js.map +1 -0
- package/build-module/avatar/user-control.js +52 -0
- package/build-module/avatar/user-control.js.map +1 -0
- package/build-module/column/index.js +2 -1
- package/build-module/column/index.js.map +1 -1
- package/build-module/comment-author-avatar/index.js +1 -0
- package/build-module/comment-author-avatar/index.js.map +1 -1
- package/build-module/comment-date/edit.js +13 -30
- package/build-module/comment-date/edit.js.map +1 -1
- package/build-module/comment-template/edit.js +79 -52
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/cover/edit.js +23 -34
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/embed/variations.js +2 -2
- package/build-module/embed/variations.js.map +1 -1
- package/build-module/gallery/edit.js +17 -5
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.js +1 -1
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/gap-styles.js +22 -0
- package/build-module/gallery/gap-styles.js.map +1 -0
- package/build-module/gallery/index.js +17 -1
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/group/index.js +3 -1
- package/build-module/group/index.js.map +1 -1
- package/build-module/group/variations.js +1 -2
- package/build-module/group/variations.js.map +1 -1
- package/build-module/image/image.js +3 -1
- package/build-module/image/image.js.map +1 -1
- package/build-module/index.js +5 -2
- package/build-module/index.js.map +1 -1
- package/build-module/list/index.js +5 -1
- package/build-module/list/index.js.map +1 -1
- package/build-module/list/v2/edit.js +69 -0
- package/build-module/list/v2/edit.js.map +1 -0
- package/build-module/list/v2/index.js +19 -0
- package/build-module/list/v2/index.js.map +1 -0
- package/build-module/list/v2/save.js +23 -0
- package/build-module/list/v2/save.js.map +1 -0
- package/build-module/list/v2/transforms.js +111 -0
- package/build-module/list/v2/transforms.js.map +1 -0
- package/build-module/list-item/edit.js +37 -0
- package/build-module/list-item/edit.js.map +1 -0
- package/build-module/list-item/index.js +53 -0
- package/build-module/list-item/index.js.map +1 -0
- package/build-module/list-item/save.js +15 -0
- package/build-module/list-item/save.js.map +1 -0
- package/build-module/media-text/edit.js +3 -1
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/navigation/use-navigation-entities.js +27 -54
- package/build-module/navigation/use-navigation-entities.js.map +1 -1
- package/build-module/navigation-link/edit.js +88 -33
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/post-date/edit.js +32 -43
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +2 -1
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/pullquote/edit.js +6 -3
- package/build-module/pullquote/edit.js.map +1 -1
- package/build-module/query/variations.js +4 -4
- package/build-module/query/variations.js.map +1 -1
- package/build-module/query-no-results/edit.js +18 -0
- package/build-module/query-no-results/edit.js.map +1 -0
- package/build-module/query-no-results/index.js +40 -0
- package/build-module/query-no-results/index.js.map +1 -0
- package/build-module/query-no-results/save.js +10 -0
- package/build-module/query-no-results/save.js.map +1 -0
- package/build-module/search/edit.js +2 -3
- package/build-module/search/edit.js.map +1 -1
- package/build-module/separator/deprecated.js +70 -0
- package/build-module/separator/deprecated.js.map +1 -0
- package/build-module/separator/edit.js +31 -22
- package/build-module/separator/edit.js.map +1 -1
- package/build-module/separator/index.js +16 -7
- package/build-module/separator/index.js.map +1 -1
- package/build-module/separator/save.js +19 -14
- package/build-module/separator/save.js.map +1 -1
- package/build-module/separator/use-deprecated-opacity.js +30 -0
- package/build-module/separator/use-deprecated-opacity.js.map +1 -0
- package/build-module/social-links/edit.js +15 -4
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/social-links/index.js +1 -1
- package/build-module/spacer/controls.js +8 -19
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/spacer/controls.native.js +2 -1
- package/build-module/spacer/controls.native.js.map +1 -1
- package/build-module/spacer/edit.js +3 -3
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/table/deprecated.js +1 -1
- package/build-module/table/deprecated.js.map +1 -1
- package/build-module/tag-cloud/edit.js +60 -4
- 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-style/avatar/editor-rtl.css +79 -0
- package/build-style/avatar/editor.css +79 -0
- package/build-style/editor-rtl.css +23 -2
- package/build-style/editor.css +23 -2
- package/build-style/gallery/editor-rtl.css +0 -1
- package/build-style/gallery/editor.css +0 -1
- package/build-style/gallery/style-rtl.css +102 -169
- package/build-style/gallery/style.css +102 -169
- package/build-style/image/style-rtl.css +2 -0
- package/build-style/image/style.css +2 -0
- package/build-style/navigation-link/editor-rtl.css +13 -0
- package/build-style/navigation-link/editor.css +13 -0
- package/build-style/pullquote/style-rtl.css +0 -4
- package/build-style/pullquote/style.css +0 -4
- package/build-style/separator/editor-rtl.css +3 -0
- package/build-style/separator/editor.css +3 -0
- package/build-style/separator/theme-rtl.css +7 -1
- package/build-style/separator/theme.css +7 -1
- package/build-style/site-logo/editor-rtl.css +3 -1
- package/build-style/site-logo/editor.css +3 -1
- package/build-style/style-rtl.css +104 -173
- package/build-style/style.css +104 -173
- package/build-style/theme-rtl.css +7 -1
- package/build-style/theme.css +7 -1
- package/package.json +28 -28
- package/src/avatar/block.json +53 -0
- package/src/avatar/edit.js +222 -0
- package/src/avatar/editor.scss +3 -0
- package/src/avatar/hooks.js +96 -0
- package/src/avatar/index.js +18 -0
- package/src/avatar/index.php +146 -0
- package/src/avatar/user-control.js +56 -0
- package/src/column/block.json +2 -1
- package/src/comment-author-avatar/block.json +1 -0
- package/src/comment-date/edit.js +20 -30
- package/src/comment-template/edit.js +65 -44
- package/src/cover/edit.js +26 -31
- package/src/editor.scss +1 -0
- package/src/embed/variations.js +2 -2
- package/src/gallery/block.json +17 -1
- package/src/gallery/deprecated.scss +2 -2
- package/src/gallery/edit.js +15 -8
- package/src/gallery/editor.scss +0 -1
- package/src/gallery/gallery.js +8 -7
- package/src/gallery/gap-styles.js +21 -0
- package/src/gallery/index.php +42 -1
- package/src/gallery/style.scss +11 -44
- package/src/group/block.json +3 -1
- package/src/group/variations.js +1 -1
- package/src/image/image.js +4 -1
- package/src/image/style.scss +3 -0
- package/src/index.js +6 -1
- package/src/list/index.js +6 -1
- package/src/list/v2/edit.js +77 -0
- package/src/list/v2/index.js +20 -0
- package/src/list/v2/save.js +18 -0
- package/src/list/v2/transforms.js +116 -0
- package/src/list-item/block.json +26 -0
- package/src/list-item/edit.js +47 -0
- package/src/list-item/index.js +27 -0
- package/src/list-item/save.js +13 -0
- package/src/media-text/edit.js +1 -1
- package/src/navigation/index.php +22 -2
- package/src/navigation/use-navigation-entities.js +37 -73
- package/src/navigation-link/edit.js +145 -61
- package/src/navigation-link/editor.scss +11 -0
- package/src/post-date/edit.js +63 -52
- package/src/post-date/index.php +1 -1
- package/src/post-date/test/edit.js +17 -0
- package/src/post-featured-image/edit.js +9 -1
- package/src/post-featured-image/index.php +2 -1
- package/src/pullquote/edit.js +4 -3
- package/src/pullquote/style.scss +0 -5
- package/src/query/variations.js +4 -0
- package/src/query-no-results/block.json +20 -0
- package/src/query-no-results/edit.js +28 -0
- package/src/query-no-results/index.js +20 -0
- package/src/query-no-results/index.php +59 -0
- package/src/query-no-results/save.js +8 -0
- package/src/search/edit.js +1 -2
- package/src/separator/block.json +13 -6
- package/src/separator/deprecated.js +57 -0
- package/src/separator/deprecated.scss +6 -0
- package/src/separator/edit.js +36 -14
- package/src/separator/editor.scss +6 -0
- package/src/separator/index.js +2 -0
- package/src/separator/save.js +22 -14
- package/src/separator/test/edit.js +113 -0
- package/src/separator/theme.scss +7 -1
- package/src/separator/use-deprecated-opacity.js +41 -0
- package/src/site-logo/editor.scss +3 -1
- package/src/social-links/block.json +1 -1
- package/src/social-links/edit.js +15 -5
- package/src/spacer/controls.js +12 -18
- package/src/spacer/controls.native.js +2 -1
- package/src/spacer/edit.js +3 -6
- package/src/table/deprecated.js +5 -1
- package/src/tag-cloud/block.json +8 -0
- package/src/tag-cloud/edit.js +82 -2
- package/src/tag-cloud/index.php +6 -0
- package/build/separator/separator-settings.js +0 -36
- package/build/separator/separator-settings.js.map +0 -1
- package/build-module/separator/separator-settings.js +0 -27
- package/build-module/separator/separator-settings.js.map +0 -1
- package/src/separator/separator-settings.js +0 -24
|
@@ -20,7 +20,7 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
20
20
|
import { useCommentQueryArgs, useCommentTree } from './hooks';
|
|
21
21
|
|
|
22
22
|
const TEMPLATE = [
|
|
23
|
-
[ 'core/
|
|
23
|
+
[ 'core/avatar' ],
|
|
24
24
|
[ 'core/comment-author-name' ],
|
|
25
25
|
[ 'core/comment-date' ],
|
|
26
26
|
[ 'core/comment-content' ],
|
|
@@ -31,6 +31,10 @@ const TEMPLATE = [
|
|
|
31
31
|
/**
|
|
32
32
|
* Function that returns a comment structure that will be rendered with default placehoders.
|
|
33
33
|
*
|
|
34
|
+
* Each comment has a `commentId` property that is always a negative number in
|
|
35
|
+
* case of the placeholders. This is to ensure that the comment does not
|
|
36
|
+
* conflict with the actual (real) comments.
|
|
37
|
+
*
|
|
34
38
|
* @param {Object} settings Discussion Settings.
|
|
35
39
|
* @param {number} [settings.perPage] - Comments per page setting or block attribute.
|
|
36
40
|
* @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.
|
|
@@ -54,12 +58,13 @@ const getCommentsPlaceholder = ( {
|
|
|
54
58
|
perPage <= commentsDepth ? perPage : commentsDepth;
|
|
55
59
|
if ( ! threadComments || defaultCommentsToShow === 1 ) {
|
|
56
60
|
// If displaying threaded comments is disabled, we only show one comment
|
|
57
|
-
|
|
61
|
+
// A commentId is negative in order to avoid conflicts with the actual comments.
|
|
62
|
+
return [ { commentId: -1, children: [] } ];
|
|
58
63
|
} else if ( defaultCommentsToShow === 2 ) {
|
|
59
64
|
return [
|
|
60
65
|
{
|
|
61
|
-
commentId:
|
|
62
|
-
children: [ { commentId:
|
|
66
|
+
commentId: -1,
|
|
67
|
+
children: [ { commentId: -2, children: [] } ],
|
|
63
68
|
},
|
|
64
69
|
];
|
|
65
70
|
}
|
|
@@ -67,11 +72,11 @@ const getCommentsPlaceholder = ( {
|
|
|
67
72
|
// In case that the value is set but larger than 3 we truncate it to 3.
|
|
68
73
|
return [
|
|
69
74
|
{
|
|
70
|
-
commentId:
|
|
75
|
+
commentId: -1,
|
|
71
76
|
children: [
|
|
72
77
|
{
|
|
73
|
-
commentId:
|
|
74
|
-
children: [ { commentId:
|
|
78
|
+
commentId: -2,
|
|
79
|
+
children: [ { commentId: -3, children: [] } ],
|
|
75
80
|
},
|
|
76
81
|
],
|
|
77
82
|
},
|
|
@@ -81,29 +86,32 @@ const getCommentsPlaceholder = ( {
|
|
|
81
86
|
/**
|
|
82
87
|
* Component which renders the inner blocks of the Comment Template.
|
|
83
88
|
*
|
|
84
|
-
* @param {Object} props
|
|
85
|
-
* @param {Array} [props.comment]
|
|
86
|
-
* @param {Array} [props.
|
|
87
|
-
* @param {Array} [props.
|
|
88
|
-
* @param {Array} [props.
|
|
89
|
-
* @param {Array} [props.blocks]
|
|
90
|
-
*
|
|
89
|
+
* @param {Object} props Component props.
|
|
90
|
+
* @param {Array} [props.comment] - A comment object.
|
|
91
|
+
* @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.
|
|
92
|
+
* @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.
|
|
93
|
+
* @param {Array} [props.firstCommentId] - ID of the first comment in the array.
|
|
94
|
+
* @param {Array} [props.blocks] - Array of blocks returned from
|
|
95
|
+
* getBlocks() in parent .
|
|
91
96
|
* @return {WPElement} Inner blocks of the Comment Template
|
|
92
97
|
*/
|
|
93
98
|
function CommentTemplateInnerBlocks( {
|
|
94
99
|
comment,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
activeCommentId,
|
|
101
|
+
setActiveCommentId,
|
|
102
|
+
firstCommentId,
|
|
98
103
|
blocks,
|
|
99
104
|
} ) {
|
|
100
105
|
const { children, ...innerBlocksProps } = useInnerBlocksProps(
|
|
101
106
|
{},
|
|
102
107
|
{ template: TEMPLATE }
|
|
103
108
|
);
|
|
109
|
+
|
|
104
110
|
return (
|
|
105
111
|
<li { ...innerBlocksProps }>
|
|
106
|
-
{ comment === (
|
|
112
|
+
{ comment.commentId === ( activeCommentId || firstCommentId )
|
|
113
|
+
? children
|
|
114
|
+
: null }
|
|
107
115
|
|
|
108
116
|
{ /* To avoid flicker when switching active block contexts, a preview
|
|
109
117
|
is ALWAYS rendered and the preview for the active block is hidden.
|
|
@@ -114,17 +122,20 @@ function CommentTemplateInnerBlocks( {
|
|
|
114
122
|
block. */ }
|
|
115
123
|
<MemoizedCommentTemplatePreview
|
|
116
124
|
blocks={ blocks }
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
isHidden={
|
|
125
|
+
commentId={ comment.commentId }
|
|
126
|
+
setActiveCommentId={ setActiveCommentId }
|
|
127
|
+
isHidden={
|
|
128
|
+
comment.commentId === ( activeCommentId || firstCommentId )
|
|
129
|
+
}
|
|
120
130
|
/>
|
|
121
131
|
|
|
122
132
|
{ comment?.children?.length > 0 ? (
|
|
123
133
|
<CommentsList
|
|
124
134
|
comments={ comment.children }
|
|
125
|
-
|
|
126
|
-
|
|
135
|
+
activeCommentId={ activeCommentId }
|
|
136
|
+
setActiveCommentId={ setActiveCommentId }
|
|
127
137
|
blocks={ blocks }
|
|
138
|
+
firstCommentId={ firstCommentId }
|
|
128
139
|
/>
|
|
129
140
|
) : null }
|
|
130
141
|
</li>
|
|
@@ -133,8 +144,8 @@ function CommentTemplateInnerBlocks( {
|
|
|
133
144
|
|
|
134
145
|
const CommentTemplatePreview = ( {
|
|
135
146
|
blocks,
|
|
136
|
-
|
|
137
|
-
|
|
147
|
+
commentId,
|
|
148
|
+
setActiveCommentId,
|
|
138
149
|
isHidden,
|
|
139
150
|
} ) => {
|
|
140
151
|
const blockPreviewProps = useBlockPreview( {
|
|
@@ -142,7 +153,7 @@ const CommentTemplatePreview = ( {
|
|
|
142
153
|
} );
|
|
143
154
|
|
|
144
155
|
const handleOnClick = () => {
|
|
145
|
-
|
|
156
|
+
setActiveCommentId( commentId );
|
|
146
157
|
};
|
|
147
158
|
|
|
148
159
|
// We have to hide the preview block if the `comment` props points to
|
|
@@ -172,35 +183,44 @@ const MemoizedCommentTemplatePreview = memo( CommentTemplatePreview );
|
|
|
172
183
|
/**
|
|
173
184
|
* Component that renders a list of (nested) comments. It is called recursively.
|
|
174
185
|
*
|
|
175
|
-
* @param {Object} props
|
|
176
|
-
* @param {Array} [props.comments]
|
|
177
|
-
* @param {Array} [props.blockProps]
|
|
178
|
-
* @param {Array} [props.
|
|
179
|
-
* @param {Array} [props.
|
|
180
|
-
* @param {Array} [props.blocks]
|
|
181
|
-
*
|
|
186
|
+
* @param {Object} props Component props.
|
|
187
|
+
* @param {Array} [props.comments] - Array of comment objects.
|
|
188
|
+
* @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.
|
|
189
|
+
* @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.
|
|
190
|
+
* @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.
|
|
191
|
+
* @param {Array} [props.blocks] - Array of blocks returned from getBlocks() in parent.
|
|
192
|
+
* @param {Object} [props.firstCommentId] - The ID of the first comment in the array of
|
|
193
|
+
* comment objects.
|
|
182
194
|
* @return {WPElement} List of comments.
|
|
183
195
|
*/
|
|
184
196
|
const CommentsList = ( {
|
|
185
197
|
comments,
|
|
186
198
|
blockProps,
|
|
187
|
-
|
|
188
|
-
|
|
199
|
+
activeCommentId,
|
|
200
|
+
setActiveCommentId,
|
|
189
201
|
blocks,
|
|
202
|
+
firstCommentId,
|
|
190
203
|
} ) => (
|
|
191
204
|
<ol { ...blockProps }>
|
|
192
205
|
{ comments &&
|
|
193
|
-
comments.map( ( comment, index ) => (
|
|
206
|
+
comments.map( ( { commentId, ...comment }, index ) => (
|
|
194
207
|
<BlockContextProvider
|
|
195
208
|
key={ comment.commentId || index }
|
|
196
|
-
value={
|
|
209
|
+
value={ {
|
|
210
|
+
// If the commentId is negative it means that this comment is a
|
|
211
|
+
// "placeholder" and that the block is most likely being used in the
|
|
212
|
+
// site editor. In this case, we have to set the commentId to `null`
|
|
213
|
+
// because otherwise the (non-existent) comment with a negative ID
|
|
214
|
+
// would be reqested from the REST API.
|
|
215
|
+
commentId: commentId < 0 ? null : commentId,
|
|
216
|
+
} }
|
|
197
217
|
>
|
|
198
218
|
<CommentTemplateInnerBlocks
|
|
199
|
-
comment={ comment }
|
|
200
|
-
|
|
201
|
-
|
|
219
|
+
comment={ { commentId, ...comment } }
|
|
220
|
+
activeCommentId={ activeCommentId }
|
|
221
|
+
setActiveCommentId={ setActiveCommentId }
|
|
202
222
|
blocks={ blocks }
|
|
203
|
-
|
|
223
|
+
firstCommentId={ firstCommentId }
|
|
204
224
|
/>
|
|
205
225
|
</BlockContextProvider>
|
|
206
226
|
) ) }
|
|
@@ -219,7 +239,7 @@ export default function CommentTemplateEdit( {
|
|
|
219
239
|
} ) {
|
|
220
240
|
const blockProps = useBlockProps();
|
|
221
241
|
|
|
222
|
-
const [
|
|
242
|
+
const [ activeCommentId, setActiveCommentId ] = useState();
|
|
223
243
|
const { commentOrder, threadCommentsDepth, threadComments } = useSelect(
|
|
224
244
|
( select ) => {
|
|
225
245
|
const { getSettings } = select( blockEditorStore );
|
|
@@ -285,8 +305,9 @@ export default function CommentTemplateEdit( {
|
|
|
285
305
|
comments={ commentTree }
|
|
286
306
|
blockProps={ blockProps }
|
|
287
307
|
blocks={ blocks }
|
|
288
|
-
|
|
289
|
-
|
|
308
|
+
activeCommentId={ activeCommentId }
|
|
309
|
+
setActiveCommentId={ setActiveCommentId }
|
|
310
|
+
firstCommentId={ commentTree[ 0 ]?.commentId }
|
|
290
311
|
/>
|
|
291
312
|
);
|
|
292
313
|
}
|
package/src/cover/edit.js
CHANGED
|
@@ -9,7 +9,13 @@ import namesPlugin from 'colord/plugins/names';
|
|
|
9
9
|
/**
|
|
10
10
|
* WordPress dependencies
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
Fragment,
|
|
14
|
+
useEffect,
|
|
15
|
+
useRef,
|
|
16
|
+
useState,
|
|
17
|
+
useMemo,
|
|
18
|
+
} from '@wordpress/element';
|
|
13
19
|
import {
|
|
14
20
|
BaseControl,
|
|
15
21
|
Button,
|
|
@@ -22,10 +28,11 @@ import {
|
|
|
22
28
|
Spinner,
|
|
23
29
|
TextareaControl,
|
|
24
30
|
ToggleControl,
|
|
25
|
-
withNotices,
|
|
26
31
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
27
32
|
__experimentalBoxControl as BoxControl,
|
|
28
33
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
34
|
+
__experimentalUnitControl as UnitControl,
|
|
35
|
+
__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
|
|
29
36
|
} from '@wordpress/components';
|
|
30
37
|
import { compose, useInstanceId } from '@wordpress/compose';
|
|
31
38
|
import {
|
|
@@ -41,7 +48,6 @@ import {
|
|
|
41
48
|
useInnerBlocksProps,
|
|
42
49
|
__experimentalUseGradient,
|
|
43
50
|
__experimentalPanelColorGradientSettings as PanelColorGradientSettings,
|
|
44
|
-
__experimentalUnitControl as UnitControl,
|
|
45
51
|
__experimentalBlockAlignmentMatrixControl as BlockAlignmentMatrixControl,
|
|
46
52
|
__experimentalBlockFullHeightAligmentControl as FullHeightAlignmentControl,
|
|
47
53
|
store as blockEditorStore,
|
|
@@ -50,6 +56,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
50
56
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
51
57
|
import { cover as icon } from '@wordpress/icons';
|
|
52
58
|
import { isBlobURL } from '@wordpress/blob';
|
|
59
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
53
60
|
|
|
54
61
|
/**
|
|
55
62
|
* Internal dependencies
|
|
@@ -96,8 +103,6 @@ function CoverHeightInput( {
|
|
|
96
103
|
unit = 'px',
|
|
97
104
|
value = '',
|
|
98
105
|
} ) {
|
|
99
|
-
const [ temporaryInput, setTemporaryInput ] = useState( null );
|
|
100
|
-
|
|
101
106
|
const instanceId = useInstanceId( UnitControl );
|
|
102
107
|
const inputId = `block-cover-height-input-${ instanceId }`;
|
|
103
108
|
const isPx = unit === 'px';
|
|
@@ -120,20 +125,16 @@ function CoverHeightInput( {
|
|
|
120
125
|
: undefined;
|
|
121
126
|
|
|
122
127
|
if ( isNaN( inputValue ) && inputValue !== undefined ) {
|
|
123
|
-
setTemporaryInput( unprocessedValue );
|
|
124
128
|
return;
|
|
125
129
|
}
|
|
126
|
-
setTemporaryInput( null );
|
|
127
130
|
onChange( inputValue );
|
|
128
131
|
};
|
|
129
132
|
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
};
|
|
133
|
+
const computedValue = useMemo( () => {
|
|
134
|
+
const [ parsedQuantity ] = parseQuantityAndUnitFromRawValue( value );
|
|
135
|
+
return [ parsedQuantity, unit ].join( '' );
|
|
136
|
+
}, [ unit, value ] );
|
|
135
137
|
|
|
136
|
-
const inputValue = temporaryInput !== null ? temporaryInput : value;
|
|
137
138
|
const min = isPx ? COVER_MIN_HEIGHT : 0;
|
|
138
139
|
|
|
139
140
|
return (
|
|
@@ -142,13 +143,11 @@ function CoverHeightInput( {
|
|
|
142
143
|
id={ inputId }
|
|
143
144
|
isResetValueOnUnitChange
|
|
144
145
|
min={ min }
|
|
145
|
-
onBlur={ handleOnBlur }
|
|
146
146
|
onChange={ handleOnChange }
|
|
147
147
|
onUnitChange={ onUnitChange }
|
|
148
148
|
style={ { maxWidth: 80 } }
|
|
149
|
-
unit={ unit }
|
|
150
149
|
units={ units }
|
|
151
|
-
value={
|
|
150
|
+
value={ computedValue }
|
|
152
151
|
/>
|
|
153
152
|
</BaseControl>
|
|
154
153
|
);
|
|
@@ -266,12 +265,10 @@ const isTemporaryMedia = ( id, url ) => ! id && isBlobURL( url );
|
|
|
266
265
|
function CoverPlaceholder( {
|
|
267
266
|
disableMediaButtons = false,
|
|
268
267
|
children,
|
|
269
|
-
noticeUI,
|
|
270
|
-
noticeOperations,
|
|
271
268
|
onSelectMedia,
|
|
269
|
+
onError,
|
|
272
270
|
style,
|
|
273
271
|
} ) {
|
|
274
|
-
const { removeAllNotices, createErrorNotice } = noticeOperations;
|
|
275
272
|
return (
|
|
276
273
|
<MediaPlaceholder
|
|
277
274
|
icon={ <BlockIcon icon={ icon } /> }
|
|
@@ -284,12 +281,8 @@ function CoverPlaceholder( {
|
|
|
284
281
|
onSelect={ onSelectMedia }
|
|
285
282
|
accept="image/*,video/*"
|
|
286
283
|
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
287
|
-
notices={ noticeUI }
|
|
288
284
|
disableMediaButtons={ disableMediaButtons }
|
|
289
|
-
onError={
|
|
290
|
-
removeAllNotices();
|
|
291
|
-
createErrorNotice( message );
|
|
292
|
-
} }
|
|
285
|
+
onError={ onError }
|
|
293
286
|
style={ style }
|
|
294
287
|
>
|
|
295
288
|
{ children }
|
|
@@ -301,8 +294,6 @@ function CoverEdit( {
|
|
|
301
294
|
attributes,
|
|
302
295
|
clientId,
|
|
303
296
|
isSelected,
|
|
304
|
-
noticeUI,
|
|
305
|
-
noticeOperations,
|
|
306
297
|
overlayColor,
|
|
307
298
|
setAttributes,
|
|
308
299
|
setOverlayColor,
|
|
@@ -328,6 +319,7 @@ function CoverEdit( {
|
|
|
328
319
|
const { __unstableMarkNextChangeAsNotPersistent } = useDispatch(
|
|
329
320
|
blockEditorStore
|
|
330
321
|
);
|
|
322
|
+
const { createErrorNotice } = useDispatch( noticesStore );
|
|
331
323
|
const {
|
|
332
324
|
gradientClass,
|
|
333
325
|
gradientValue,
|
|
@@ -382,6 +374,12 @@ function CoverEdit( {
|
|
|
382
374
|
} );
|
|
383
375
|
};
|
|
384
376
|
|
|
377
|
+
const onUploadError = ( message ) => {
|
|
378
|
+
createErrorNotice( Array.isArray( message ) ? message[ 2 ] : message, {
|
|
379
|
+
type: 'snackbar',
|
|
380
|
+
} );
|
|
381
|
+
};
|
|
382
|
+
|
|
385
383
|
const isDarkElement = useRef();
|
|
386
384
|
const isCoverDark = useCoverIsDark(
|
|
387
385
|
url,
|
|
@@ -640,9 +638,8 @@ function CoverEdit( {
|
|
|
640
638
|
) }
|
|
641
639
|
>
|
|
642
640
|
<CoverPlaceholder
|
|
643
|
-
noticeUI={ noticeUI }
|
|
644
641
|
onSelectMedia={ onSelectMedia }
|
|
645
|
-
|
|
642
|
+
onError={ onUploadError }
|
|
646
643
|
style={ {
|
|
647
644
|
minHeight: minHeightWithUnit || undefined,
|
|
648
645
|
} }
|
|
@@ -763,9 +760,8 @@ function CoverEdit( {
|
|
|
763
760
|
{ isUploadingMedia && <Spinner /> }
|
|
764
761
|
<CoverPlaceholder
|
|
765
762
|
disableMediaButtons
|
|
766
|
-
noticeUI={ noticeUI }
|
|
767
763
|
onSelectMedia={ onSelectMedia }
|
|
768
|
-
|
|
764
|
+
onError={ onUploadError }
|
|
769
765
|
/>
|
|
770
766
|
<div { ...innerBlocksProps } />
|
|
771
767
|
</div>
|
|
@@ -775,5 +771,4 @@ function CoverEdit( {
|
|
|
775
771
|
|
|
776
772
|
export default compose( [
|
|
777
773
|
withColors( { overlayColor: 'background-color' } ),
|
|
778
|
-
withNotices,
|
|
779
774
|
] )( CoverEdit );
|
package/src/editor.scss
CHANGED
package/src/embed/variations.js
CHANGED
|
@@ -344,9 +344,9 @@ const variations = [
|
|
|
344
344
|
},
|
|
345
345
|
{
|
|
346
346
|
name: 'wolfram-cloud',
|
|
347
|
-
title: 'Wolfram
|
|
347
|
+
title: 'Wolfram',
|
|
348
348
|
icon: embedWolframIcon,
|
|
349
|
-
description: __( 'Embed Wolfram
|
|
349
|
+
description: __( 'Embed Wolfram notebook content.' ),
|
|
350
350
|
patterns: [ /^https?:\/\/(www\.)?wolframcloud\.com\/obj\/.+/i ],
|
|
351
351
|
attributes: { providerNameSlug: 'wolfram-cloud', responsive: true },
|
|
352
352
|
},
|
package/src/gallery/block.json
CHANGED
|
@@ -106,7 +106,23 @@
|
|
|
106
106
|
},
|
|
107
107
|
"supports": {
|
|
108
108
|
"anchor": true,
|
|
109
|
-
"align": true
|
|
109
|
+
"align": true,
|
|
110
|
+
"html": false,
|
|
111
|
+
"units": [ "px", "em", "rem", "vh", "vw" ],
|
|
112
|
+
"spacing": {
|
|
113
|
+
"blockGap": true,
|
|
114
|
+
"__experimentalDefaultControls": {
|
|
115
|
+
"blockGap": true
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"__experimentalLayout": {
|
|
119
|
+
"allowSwitching": false,
|
|
120
|
+
"allowInheriting": false,
|
|
121
|
+
"allowEditing": false,
|
|
122
|
+
"default": {
|
|
123
|
+
"type": "flex"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
110
126
|
},
|
|
111
127
|
"editorStyle": "wp-block-gallery-editor",
|
|
112
128
|
"style": "wp-block-gallery"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Deprecated gallery styles pre refactoring to use nested image blocks.
|
|
2
2
|
// https://github.com/WordPress/gutenberg/pull/25940.
|
|
3
|
-
.wp-block-gallery,
|
|
4
|
-
.blocks-gallery-grid {
|
|
3
|
+
.wp-block-gallery:not(.has-nested-images),
|
|
4
|
+
.blocks-gallery-grid:not(.has-nested-images) {
|
|
5
5
|
display: flex;
|
|
6
6
|
flex-wrap: wrap;
|
|
7
7
|
list-style-type: none;
|
package/src/gallery/edit.js
CHANGED
|
@@ -54,6 +54,7 @@ import useImageSizes from './use-image-sizes';
|
|
|
54
54
|
import useShortCodeTransform from './use-short-code-transform';
|
|
55
55
|
import useGetNewImages from './use-get-new-images';
|
|
56
56
|
import useGetMedia from './use-get-media';
|
|
57
|
+
import GapStyles from './gap-styles';
|
|
57
58
|
|
|
58
59
|
const MAX_COLUMNS = 8;
|
|
59
60
|
const linkOptions = [
|
|
@@ -99,7 +100,8 @@ function GalleryEdit( props ) {
|
|
|
99
100
|
__unstableMarkNextChangeAsNotPersistent,
|
|
100
101
|
replaceInnerBlocks,
|
|
101
102
|
updateBlockAttributes,
|
|
102
|
-
|
|
103
|
+
selectBlock,
|
|
104
|
+
clearSelectedBlock,
|
|
103
105
|
} = useDispatch( blockEditorStore );
|
|
104
106
|
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
105
107
|
|
|
@@ -155,13 +157,8 @@ function GalleryEdit( props ) {
|
|
|
155
157
|
align: undefined,
|
|
156
158
|
} );
|
|
157
159
|
} );
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if ( newImages?.length ) {
|
|
161
|
-
multiSelect(
|
|
162
|
-
newImages[ 0 ].clientId,
|
|
163
|
-
newImages[ newImages?.length - 1 ].clientId
|
|
164
|
-
);
|
|
160
|
+
if ( newImages?.length > 0 ) {
|
|
161
|
+
clearSelectedBlock();
|
|
165
162
|
}
|
|
166
163
|
}, [ newImages ] );
|
|
167
164
|
|
|
@@ -296,6 +293,10 @@ function GalleryEdit( props ) {
|
|
|
296
293
|
} );
|
|
297
294
|
} );
|
|
298
295
|
|
|
296
|
+
if ( newBlocks?.length > 0 ) {
|
|
297
|
+
selectBlock( newBlocks[ 0 ].clientId );
|
|
298
|
+
}
|
|
299
|
+
|
|
299
300
|
replaceInnerBlocks(
|
|
300
301
|
clientId,
|
|
301
302
|
concat( existingImageBlocks, newBlocks ).sort(
|
|
@@ -548,6 +549,12 @@ function GalleryEdit( props ) {
|
|
|
548
549
|
/>
|
|
549
550
|
</BlockControls>
|
|
550
551
|
{ noticeUI }
|
|
552
|
+
{ Platform.isWeb && (
|
|
553
|
+
<GapStyles
|
|
554
|
+
blockGap={ attributes.style?.spacing?.blockGap }
|
|
555
|
+
clientId={ clientId }
|
|
556
|
+
/>
|
|
557
|
+
) }
|
|
551
558
|
<Gallery
|
|
552
559
|
{ ...props }
|
|
553
560
|
images={ images }
|
package/src/gallery/editor.scss
CHANGED
package/src/gallery/gallery.js
CHANGED
|
@@ -69,13 +69,14 @@ export const Gallery = ( props ) => {
|
|
|
69
69
|
) }
|
|
70
70
|
>
|
|
71
71
|
{ children }
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
{ isSelected && ! children && (
|
|
73
|
+
<View
|
|
74
|
+
className="blocks-gallery-media-placeholder-wrapper"
|
|
75
|
+
onClick={ removeCaptionFocus }
|
|
76
|
+
>
|
|
77
|
+
{ mediaPlaceholder }
|
|
78
|
+
</View>
|
|
79
|
+
) }
|
|
79
80
|
<RichTextVisibilityHelper
|
|
80
81
|
isHidden={ ! isSelected && RichText.isEmpty( caption ) }
|
|
81
82
|
captionFocused={ captionFocused }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { BlockList } from '@wordpress/block-editor';
|
|
5
|
+
import { useContext, createPortal } from '@wordpress/element';
|
|
6
|
+
|
|
7
|
+
export default function GapStyles( { blockGap, clientId } ) {
|
|
8
|
+
const styleElement = useContext( BlockList.__unstableElementContext );
|
|
9
|
+
|
|
10
|
+
const gap = blockGap
|
|
11
|
+
? `#block-${ clientId } { --wp--style--unstable-gallery-gap: ${ blockGap } }`
|
|
12
|
+
: `#block-${ clientId } { --wp--style--unstable-gallery-gap: var( --wp--style--block-gap, 0.5em ) }`;
|
|
13
|
+
|
|
14
|
+
const GapStyle = () => {
|
|
15
|
+
return <style>{ gap }</style>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return gap && styleElement
|
|
19
|
+
? createPortal( <GapStyle />, styleElement )
|
|
20
|
+
: null;
|
|
21
|
+
}
|
package/src/gallery/index.php
CHANGED
|
@@ -32,12 +32,53 @@ function block_core_gallery_data_id_backcompatibility( $parsed_block ) {
|
|
|
32
32
|
|
|
33
33
|
add_filter( 'render_block_data', 'block_core_gallery_data_id_backcompatibility' );
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Adds a style tag for the --wp--style--unstable-gallery-gap var.
|
|
37
|
+
*
|
|
38
|
+
* The Gallery block needs to recalculate Image block width based on
|
|
39
|
+
* the current gap setting in order to maintain the number of flex columns
|
|
40
|
+
* so a css var is added to allow this.
|
|
41
|
+
*
|
|
42
|
+
* @param array $attributes Attributes of the block being rendered.
|
|
43
|
+
* @param string $content Content of the block being rendered.
|
|
44
|
+
* @return string The content of the block being rendered.
|
|
45
|
+
*/
|
|
46
|
+
function block_core_gallery_render( $attributes, $content ) {
|
|
47
|
+
$gap = _wp_array_get( $attributes, array( 'style', 'spacing', 'blockGap' ) );
|
|
48
|
+
// Skip if gap value contains unsupported characters.
|
|
49
|
+
// Regex for CSS value borrowed from `safecss_filter_attr`, and used here
|
|
50
|
+
// because we only want to match against the value, not the CSS attribute.
|
|
51
|
+
$gap = preg_match( '%[\\\(&=}]|/\*%', $gap ) ? null : $gap;
|
|
52
|
+
$id = uniqid();
|
|
53
|
+
$class = 'wp-block-gallery-' . $id;
|
|
54
|
+
$content = preg_replace(
|
|
55
|
+
'/' . preg_quote( 'class="', '/' ) . '/',
|
|
56
|
+
'class="' . $class . ' ',
|
|
57
|
+
$content,
|
|
58
|
+
1
|
|
59
|
+
);
|
|
60
|
+
$gap_value = $gap ? $gap : 'var( --wp--style--block-gap, 0.5em )';
|
|
61
|
+
$style = '.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_value . '}';
|
|
62
|
+
// Ideally styles should be loaded in the head, but blocks may be parsed
|
|
63
|
+
// after that, so loading in the footer for now.
|
|
64
|
+
// See https://core.trac.wordpress.org/ticket/53494.
|
|
65
|
+
add_action(
|
|
66
|
+
'wp_footer',
|
|
67
|
+
function () use ( $style ) {
|
|
68
|
+
echo '<style> ' . $style . '</style>';
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
return $content;
|
|
72
|
+
}
|
|
35
73
|
/**
|
|
36
74
|
* Registers the `core/gallery` block on server.
|
|
37
75
|
*/
|
|
38
76
|
function register_block_core_gallery() {
|
|
39
77
|
register_block_type_from_metadata(
|
|
40
|
-
__DIR__ . '/gallery'
|
|
78
|
+
__DIR__ . '/gallery',
|
|
79
|
+
array(
|
|
80
|
+
'render_callback' => 'block_core_gallery_render',
|
|
81
|
+
)
|
|
41
82
|
);
|
|
42
83
|
}
|
|
43
84
|
|