@wordpress/block-library 7.4.0 → 7.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/audio/edit.js +3 -15
- package/build/audio/edit.js.map +1 -1
- package/build/button/edit.native.js +7 -3
- package/build/button/edit.native.js.map +1 -1
- package/build/comment-template/edit.js +1 -3
- package/build/comment-template/edit.js.map +1 -1
- package/build/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
- package/{build-module/comments-query-loop → build/comments}/edit/comments-inspector-controls.js.map +1 -1
- package/build/{comments-query-loop → comments}/edit.js +3 -3
- package/build/comments/edit.js.map +1 -0
- package/build/{comments-query-loop → comments}/index.js +1 -1
- package/build/comments/index.js.map +1 -0
- package/build/{comments-query-loop → comments}/save.js +2 -2
- package/build/comments/save.js.map +1 -0
- package/build/comments-title/edit.js +7 -5
- package/build/comments-title/edit.js.map +1 -1
- package/build/cover/edit.js +4 -71
- package/build/cover/edit.js.map +1 -1
- package/build/cover/edit.native.js +36 -15
- package/build/cover/edit.native.js.map +1 -1
- package/build/cover/transforms.js +77 -6
- package/build/cover/transforms.js.map +1 -1
- package/build/cover/use-cover-is-dark.js +81 -0
- package/build/cover/use-cover-is-dark.js.map +1 -0
- package/build/cover/use-cover-is-dark.native.js +60 -0
- package/build/cover/use-cover-is-dark.native.js.map +1 -0
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/transforms.js +8 -4
- package/build/heading/transforms.js.map +1 -1
- package/build/index.js +4 -6
- package/build/index.js.map +1 -1
- package/build/latest-posts/edit.native.js +49 -0
- package/build/latest-posts/edit.native.js.map +1 -1
- package/build/navigation/edit/index.js +5 -28
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +5 -7
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/index.js +0 -1
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/view-modal.js +25 -0
- package/build/navigation/view-modal.js.map +1 -1
- package/build/navigation-link/edit.js +29 -30
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +14 -14
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/paragraph/edit.js +10 -0
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/use-enter.js +94 -0
- package/build/paragraph/use-enter.js.map +1 -0
- package/build/post-comment/index.js +1 -1
- package/build/post-comments/edit.js +120 -35
- package/build/post-comments/edit.js.map +1 -1
- package/build/post-comments/index.js +3 -2
- package/build/post-comments/index.js.map +1 -1
- package/build/post-comments-form/edit.js +38 -4
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-comments-form/form.js +48 -0
- package/build/post-comments-form/form.js.map +1 -0
- package/build/post-comments-form/index.js +1 -0
- package/build/post-comments-form/index.js.map +1 -1
- package/build/post-content/edit.js +1 -1
- package/build/post-content/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +1 -1
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-terms/edit.js +25 -3
- package/build/post-terms/edit.js.map +1 -1
- package/build/post-terms/index.js +8 -0
- package/build/post-terms/index.js.map +1 -1
- package/build/query-no-results/edit.js +1 -1
- package/build/query-no-results/edit.js.map +1 -1
- package/build/quote/index.js +1 -0
- package/build/quote/index.js.map +1 -1
- package/build/separator/index.js +3 -0
- package/build/separator/index.js.map +1 -1
- package/build/video/edit.js +3 -7
- package/build/video/edit.js.map +1 -1
- package/build-module/audio/edit.js +3 -15
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/button/edit.native.js +7 -3
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/comment-template/edit.js +1 -3
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
- package/build-module/comments/edit/comments-inspector-controls.js.map +1 -0
- package/build-module/{comments-query-loop → comments}/edit.js +2 -2
- package/build-module/comments/edit.js.map +1 -0
- package/build-module/{comments-query-loop → comments}/index.js +1 -1
- package/build-module/comments/index.js.map +1 -0
- package/build-module/{comments-query-loop → comments}/save.js +1 -1
- package/build-module/comments/save.js.map +1 -0
- package/build-module/comments-title/edit.js +7 -5
- package/build-module/comments-title/edit.js.map +1 -1
- package/build-module/cover/edit.js +4 -71
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/cover/edit.native.js +35 -16
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/cover/transforms.js +74 -6
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/cover/use-cover-is-dark.js +70 -0
- package/build-module/cover/use-cover-is-dark.js.map +1 -0
- package/build-module/cover/use-cover-is-dark.native.js +51 -0
- package/build-module/cover/use-cover-is-dark.native.js.map +1 -0
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/transforms.js +8 -4
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/index.js +3 -4
- package/build-module/index.js.map +1 -1
- package/build-module/latest-posts/edit.native.js +51 -2
- package/build-module/latest-posts/edit.native.js.map +1 -1
- package/build-module/navigation/edit/index.js +6 -28
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +5 -7
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/index.js +0 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/view-modal.js +24 -0
- package/build-module/navigation/view-modal.js.map +1 -1
- package/build-module/navigation-link/edit.js +29 -30
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +14 -14
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/paragraph/edit.js +9 -0
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/use-enter.js +81 -0
- package/build-module/paragraph/use-enter.js.map +1 -0
- package/build-module/post-comment/index.js +1 -1
- package/build-module/post-comments/edit.js +120 -37
- package/build-module/post-comments/edit.js.map +1 -1
- package/build-module/post-comments/index.js +3 -2
- package/build-module/post-comments/index.js.map +1 -1
- package/build-module/post-comments-form/edit.js +38 -6
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +39 -0
- package/build-module/post-comments-form/form.js.map +1 -0
- package/build-module/post-comments-form/index.js +1 -0
- package/build-module/post-comments-form/index.js.map +1 -1
- package/build-module/post-content/edit.js +1 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +1 -1
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-terms/edit.js +26 -4
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/post-terms/index.js +8 -0
- package/build-module/post-terms/index.js.map +1 -1
- package/build-module/query-no-results/edit.js +1 -1
- package/build-module/query-no-results/edit.js.map +1 -1
- package/build-module/quote/index.js +1 -0
- package/build-module/quote/index.js.map +1 -1
- package/build-module/separator/index.js +3 -0
- package/build-module/separator/index.js.map +1 -1
- package/build-module/video/edit.js +3 -7
- package/build-module/video/edit.js.map +1 -1
- package/build-style/comment-content/style-rtl.css +81 -0
- package/build-style/comment-content/style.css +81 -0
- package/build-style/{comments-query-loop → comments}/editor-rtl.css +0 -0
- package/build-style/{comments-query-loop → comments}/editor.css +0 -0
- package/build-style/cover/style-rtl.css +1 -5
- package/build-style/cover/style.css +1 -5
- package/build-style/editor-rtl.css +12 -4
- package/build-style/editor.css +12 -4
- package/build-style/latest-posts/style-rtl.css +2 -0
- package/build-style/latest-posts/style.css +4 -0
- package/build-style/navigation/style-rtl.css +3 -0
- package/build-style/navigation/style.css +3 -0
- package/build-style/post-comments/editor-rtl.css +79 -0
- package/build-style/post-comments/editor.css +79 -0
- package/build-style/post-comments/style-rtl.css +6 -4
- package/build-style/post-comments/style.css +6 -4
- package/build-style/post-comments-form/editor-rtl.css +79 -0
- package/build-style/post-comments-form/editor.css +79 -0
- package/build-style/style-rtl.css +12 -9
- package/build-style/style.css +14 -9
- package/package.json +28 -28
- package/src/audio/edit.js +2 -7
- package/src/button/edit.native.js +6 -3
- package/src/comment-author-name/index.php +7 -5
- package/src/comment-content/index.php +25 -3
- package/src/comment-content/style.scss +5 -0
- package/src/comment-edit-link/index.php +1 -4
- package/src/comment-reply-link/index.php +1 -4
- package/src/comment-template/edit.js +1 -5
- package/src/comment-template/index.php +4 -0
- package/src/{comments-query-loop → comments}/block.json +1 -1
- package/src/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
- package/src/{comments-query-loop → comments}/edit.js +2 -1
- package/src/{comments-query-loop → comments}/editor.scss +0 -0
- package/src/{comments-query-loop → comments}/index.js +0 -0
- package/src/{comments-query-loop → comments}/save.js +1 -3
- package/src/comments-pagination/index.php +4 -0
- package/src/comments-title/edit.js +20 -4
- package/src/comments-title/index.php +18 -7
- package/src/cover/edit.js +2 -67
- package/src/cover/edit.native.js +40 -13
- package/src/cover/index.php +1 -1
- package/src/cover/style.native.scss +4 -0
- package/src/cover/style.scss +1 -5
- package/src/cover/test/__snapshots__/edit.native.js.snap +6 -6
- package/src/cover/test/transforms.js +301 -0
- package/src/cover/transforms.js +112 -7
- package/src/cover/use-cover-is-dark.js +71 -0
- package/src/cover/use-cover-is-dark.native.js +51 -0
- package/src/editor.scss +3 -1
- package/src/group/block.json +1 -0
- package/src/heading/transforms.js +4 -3
- package/src/index.js +3 -6
- package/src/latest-posts/edit.native.js +56 -1
- package/src/latest-posts/style.scss +4 -0
- package/src/navigation/block.json +0 -1
- package/src/navigation/edit/index.js +6 -36
- package/src/navigation/edit/inner-blocks.js +5 -7
- package/src/navigation/style.scss +3 -0
- package/src/navigation/view-modal.js +32 -0
- package/src/navigation-link/edit.js +40 -43
- package/src/navigation-submenu/edit.js +13 -17
- package/src/paragraph/edit.js +6 -0
- package/src/paragraph/use-enter.js +103 -0
- package/src/post-author/index.php +1 -1
- package/src/post-comment/block.json +1 -1
- package/src/post-comments/block.json +3 -2
- package/src/post-comments/edit.js +174 -44
- package/src/post-comments/editor.scss +3 -0
- package/src/post-comments/index.php +2 -0
- package/src/post-comments/style.scss +6 -7
- package/src/post-comments-form/block.json +1 -0
- package/src/post-comments-form/edit.js +52 -23
- package/src/post-comments-form/editor.scss +3 -0
- package/src/post-comments-form/form.js +43 -0
- package/src/post-comments-form/index.php +9 -2
- package/src/post-content/edit.js +15 -1
- package/src/post-excerpt/edit.js +14 -1
- package/src/post-terms/block.json +8 -0
- package/src/post-terms/edit.js +28 -1
- package/src/post-terms/index.php +12 -2
- package/src/query-no-results/edit.js +1 -1
- package/src/quote/block.json +1 -0
- package/src/separator/block.json +3 -0
- package/src/video/edit.js +3 -4
- package/build/comments-query-loop/edit/comments-inspector-controls.js.map +0 -1
- package/build/comments-query-loop/edit.js.map +0 -1
- package/build/comments-query-loop/index.js.map +0 -1
- package/build/comments-query-loop/save.js.map +0 -1
- package/build/navigation-area/edit.js +0 -110
- package/build/navigation-area/edit.js.map +0 -1
- package/build/navigation-area/index.js +0 -62
- package/build/navigation-area/index.js.map +0 -1
- package/build/navigation-area/inner-blocks.js +0 -34
- package/build/navigation-area/inner-blocks.js.map +0 -1
- package/build/navigation-area/save.js +0 -18
- package/build/navigation-area/save.js.map +0 -1
- package/build-module/comments-query-loop/edit.js.map +0 -1
- package/build-module/comments-query-loop/index.js.map +0 -1
- package/build-module/comments-query-loop/save.js.map +0 -1
- package/build-module/navigation-area/edit.js +0 -94
- package/build-module/navigation-area/edit.js.map +0 -1
- package/build-module/navigation-area/index.js +0 -48
- package/build-module/navigation-area/index.js.map +0 -1
- package/build-module/navigation-area/inner-blocks.js +0 -26
- package/build-module/navigation-area/inner-blocks.js.map +0 -1
- package/build-module/navigation-area/save.js +0 -10
- package/build-module/navigation-area/save.js.map +0 -1
- package/src/navigation-area/block.json +0 -23
- package/src/navigation-area/edit.js +0 -111
- package/src/navigation-area/index.js +0 -26
- package/src/navigation-area/index.php +0 -22
- package/src/navigation-area/inner-blocks.js +0 -24
- package/src/navigation-area/save.js +0 -8
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"name": "core/post-comments",
|
|
5
5
|
"title": "Post Comments (deprecated)",
|
|
6
6
|
"category": "theme",
|
|
7
|
-
"description": "This block is deprecated. Please use the Comments
|
|
7
|
+
"description": "This block is deprecated. Please use the Comments block instead.",
|
|
8
8
|
"textdomain": "default",
|
|
9
9
|
"attributes": {
|
|
10
10
|
"textAlign": {
|
|
@@ -40,5 +40,6 @@
|
|
|
40
40
|
"wp-block-post-comments",
|
|
41
41
|
"wp-block-buttons",
|
|
42
42
|
"wp-block-button"
|
|
43
|
-
]
|
|
43
|
+
],
|
|
44
|
+
"editorStyle": "wp-block-post-comments-editor"
|
|
44
45
|
}
|
|
@@ -6,65 +6,89 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { useSelect } from '@wordpress/data';
|
|
10
9
|
import {
|
|
11
10
|
AlignmentControl,
|
|
12
11
|
BlockControls,
|
|
13
12
|
Warning,
|
|
14
13
|
useBlockProps,
|
|
14
|
+
store as blockEditorStore,
|
|
15
15
|
} from '@wordpress/block-editor';
|
|
16
|
-
import { __ } from '@wordpress/i18n';
|
|
17
|
-
import {
|
|
18
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
'comment',
|
|
26
|
-
{
|
|
27
|
-
post: postId,
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
// TODO: "No Comments" placeholder should be editable.
|
|
31
|
-
return comments && comments.length
|
|
32
|
-
? comments.map( ( comment ) => (
|
|
33
|
-
<RawHTML
|
|
34
|
-
className="wp-block-post-comments__comment"
|
|
35
|
-
key={ comment.id }
|
|
36
|
-
>
|
|
37
|
-
{ comment.content.rendered }
|
|
38
|
-
</RawHTML>
|
|
39
|
-
) )
|
|
40
|
-
: __( 'No comments.' );
|
|
41
|
-
},
|
|
42
|
-
[ postId ]
|
|
43
|
-
);
|
|
44
|
-
}
|
|
16
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
17
|
+
import { useSelect } from '@wordpress/data';
|
|
18
|
+
import { useEntityProp, store as coreStore } from '@wordpress/core-data';
|
|
19
|
+
import { __experimentalUseDisabled as useDisabled } from '@wordpress/compose';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Internal dependencies
|
|
23
|
+
*/
|
|
24
|
+
import CommentsForm from '../post-comments-form/form';
|
|
45
25
|
|
|
46
26
|
export default function PostCommentsEdit( {
|
|
47
|
-
attributes,
|
|
27
|
+
attributes: { textAlign },
|
|
48
28
|
setAttributes,
|
|
49
|
-
context,
|
|
29
|
+
context: { postType, postId },
|
|
50
30
|
} ) {
|
|
51
|
-
|
|
52
|
-
|
|
31
|
+
let [ postTitle ] = useEntityProp( 'postType', postType, 'title', postId );
|
|
32
|
+
postTitle = postTitle || __( 'Post Title' );
|
|
33
|
+
|
|
34
|
+
const [ commentStatus ] = useEntityProp(
|
|
35
|
+
'postType',
|
|
36
|
+
postType,
|
|
37
|
+
'comment_status',
|
|
38
|
+
postId
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const { avatarURL, defaultCommentStatus } = useSelect(
|
|
42
|
+
( select ) =>
|
|
43
|
+
select( blockEditorStore ).getSettings()
|
|
44
|
+
.__experimentalDiscussionSettings
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const isSiteEditor = postType === undefined || postId === undefined;
|
|
48
|
+
|
|
49
|
+
const postTypeSupportsComments = useSelect( ( select ) =>
|
|
50
|
+
postType
|
|
51
|
+
? !! select( coreStore ).getPostType( postType )?.supports.comments
|
|
52
|
+
: false
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
let warning = __(
|
|
56
|
+
'Post Comments block: This is just a placeholder, not a real comment. The final styling may differ because it also depends on the current theme. For better compatibility with the Block Editor, please consider replacing this block with the "Comments" block.'
|
|
57
|
+
);
|
|
58
|
+
let showPlaceholder = true;
|
|
59
|
+
|
|
60
|
+
if ( ! isSiteEditor && 'open' !== commentStatus ) {
|
|
61
|
+
if ( 'closed' === commentStatus ) {
|
|
62
|
+
warning = sprintf(
|
|
63
|
+
/* translators: 1: Post type (i.e. "post", "page") */
|
|
64
|
+
__(
|
|
65
|
+
'Post Comments block: Comments to this %s are not allowed.'
|
|
66
|
+
),
|
|
67
|
+
postType
|
|
68
|
+
);
|
|
69
|
+
showPlaceholder = false;
|
|
70
|
+
} else if ( ! postTypeSupportsComments ) {
|
|
71
|
+
warning = sprintf(
|
|
72
|
+
/* translators: 1: Post type (i.e. "post", "page") */
|
|
73
|
+
__(
|
|
74
|
+
'Post Comments block: Comments for this post type (%s) are not enabled.'
|
|
75
|
+
),
|
|
76
|
+
postType
|
|
77
|
+
);
|
|
78
|
+
showPlaceholder = false;
|
|
79
|
+
} else if ( 'open' !== defaultCommentStatus ) {
|
|
80
|
+
warning = __( 'Post Comments block: Comments are not enabled.' );
|
|
81
|
+
showPlaceholder = false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
53
85
|
const blockProps = useBlockProps( {
|
|
54
86
|
className: classnames( {
|
|
55
87
|
[ `has-text-align-${ textAlign }` ]: textAlign,
|
|
56
88
|
} ),
|
|
57
89
|
} );
|
|
58
90
|
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<div { ...blockProps }>
|
|
62
|
-
<Warning>
|
|
63
|
-
{ __( 'Post comments block: no post found.' ) }
|
|
64
|
-
</Warning>
|
|
65
|
-
</div>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
91
|
+
const disabledRef = useDisabled();
|
|
68
92
|
|
|
69
93
|
return (
|
|
70
94
|
<>
|
|
@@ -78,7 +102,113 @@ export default function PostCommentsEdit( {
|
|
|
78
102
|
</BlockControls>
|
|
79
103
|
|
|
80
104
|
<div { ...blockProps }>
|
|
81
|
-
<
|
|
105
|
+
<Warning>{ warning }</Warning>
|
|
106
|
+
|
|
107
|
+
{ showPlaceholder && (
|
|
108
|
+
<div
|
|
109
|
+
className="wp-block-post-comments__placeholder"
|
|
110
|
+
ref={ disabledRef }
|
|
111
|
+
>
|
|
112
|
+
<h3>
|
|
113
|
+
{ __( 'One response to' ) } “{ postTitle }”
|
|
114
|
+
</h3>
|
|
115
|
+
|
|
116
|
+
<div className="navigation">
|
|
117
|
+
<div className="alignleft">
|
|
118
|
+
<a href="#top">« { __( 'Older Comments' ) }</a>
|
|
119
|
+
</div>
|
|
120
|
+
<div className="alignright">
|
|
121
|
+
<a href="#top">{ __( 'Newer Comments' ) } »</a>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
|
|
125
|
+
<ol className="commentlist">
|
|
126
|
+
<li className="comment even thread-even depth-1">
|
|
127
|
+
<article className="comment-body">
|
|
128
|
+
<footer className="comment-meta">
|
|
129
|
+
<div className="comment-author vcard">
|
|
130
|
+
<img
|
|
131
|
+
alt="Commenter Avatar"
|
|
132
|
+
src={ avatarURL }
|
|
133
|
+
className="avatar avatar-32 photo"
|
|
134
|
+
height="32"
|
|
135
|
+
width="32"
|
|
136
|
+
loading="lazy"
|
|
137
|
+
/>
|
|
138
|
+
<b className="fn">
|
|
139
|
+
<a href="#top" className="url">
|
|
140
|
+
{ __(
|
|
141
|
+
'A WordPress Commenter'
|
|
142
|
+
) }
|
|
143
|
+
</a>
|
|
144
|
+
</b>{ ' ' }
|
|
145
|
+
<span className="says">
|
|
146
|
+
{ __( 'says' ) }:
|
|
147
|
+
</span>
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
<div className="comment-metadata">
|
|
151
|
+
<a href="#top">
|
|
152
|
+
<time dateTime="2000-01-01T00:00:00+00:00">
|
|
153
|
+
{ __(
|
|
154
|
+
'January 1, 2000 at 00:00 am'
|
|
155
|
+
) }
|
|
156
|
+
</time>
|
|
157
|
+
</a>{ ' ' }
|
|
158
|
+
<span className="edit-link">
|
|
159
|
+
<a
|
|
160
|
+
className="comment-edit-link"
|
|
161
|
+
href="#top"
|
|
162
|
+
>
|
|
163
|
+
{ __( 'Edit' ) }
|
|
164
|
+
</a>
|
|
165
|
+
</span>
|
|
166
|
+
</div>
|
|
167
|
+
</footer>
|
|
168
|
+
|
|
169
|
+
<div className="comment-content">
|
|
170
|
+
<p>
|
|
171
|
+
{ __( 'Hi, this is a comment.' ) }
|
|
172
|
+
<br />
|
|
173
|
+
{ __(
|
|
174
|
+
'To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.'
|
|
175
|
+
) }
|
|
176
|
+
<br />
|
|
177
|
+
{ __(
|
|
178
|
+
'Commenter avatars come from'
|
|
179
|
+
) }{ ' ' }
|
|
180
|
+
<a href="https://gravatar.com/">
|
|
181
|
+
Gravatar
|
|
182
|
+
</a>
|
|
183
|
+
.
|
|
184
|
+
</p>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<div className="reply">
|
|
188
|
+
<a
|
|
189
|
+
className="comment-reply-link"
|
|
190
|
+
href="#top"
|
|
191
|
+
aria-label="Reply to A WordPress Commenter"
|
|
192
|
+
>
|
|
193
|
+
{ __( 'Reply' ) }
|
|
194
|
+
</a>
|
|
195
|
+
</div>
|
|
196
|
+
</article>
|
|
197
|
+
</li>
|
|
198
|
+
</ol>
|
|
199
|
+
|
|
200
|
+
<div className="navigation">
|
|
201
|
+
<div className="alignleft">
|
|
202
|
+
<a href="#top">« { __( 'Older Comments' ) }</a>
|
|
203
|
+
</div>
|
|
204
|
+
<div className="alignright">
|
|
205
|
+
<a href="#top">{ __( 'Newer Comments' ) } »</a>
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
<CommentsForm />
|
|
210
|
+
</div>
|
|
211
|
+
) }
|
|
82
212
|
</div>
|
|
83
213
|
</>
|
|
84
214
|
);
|
|
@@ -51,6 +51,8 @@ function render_block_core_post_comments( $attributes, $content, $block ) {
|
|
|
51
51
|
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
|
|
52
52
|
$output = ob_get_clean();
|
|
53
53
|
|
|
54
|
+
wp_enqueue_script( 'comment-reply' );
|
|
55
|
+
|
|
54
56
|
return sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $output );
|
|
55
57
|
}
|
|
56
58
|
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
.wp-block-post-comments {
|
|
2
|
-
// Remove extraneous top padding added to the first heading of the block.
|
|
3
|
-
> h3:first-of-type {
|
|
4
|
-
margin-top: 0;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
2
|
.commentlist {
|
|
3
|
+
clear: both;
|
|
8
4
|
list-style: none;
|
|
9
5
|
margin: 0;
|
|
10
6
|
padding: 0;
|
|
@@ -48,11 +44,14 @@
|
|
|
48
44
|
.comment-meta {
|
|
49
45
|
font-size: 0.875em;
|
|
50
46
|
line-height: 1.5;
|
|
51
|
-
margin-left: -3.25em;
|
|
52
|
-
|
|
53
47
|
b {
|
|
54
48
|
font-weight: normal;
|
|
55
49
|
}
|
|
50
|
+
.comment-awaiting-moderation {
|
|
51
|
+
margin-top: 1em;
|
|
52
|
+
margin-bottom: 1em;
|
|
53
|
+
display: block;
|
|
54
|
+
}
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
.comment-body .commentmetadata {
|
|
@@ -11,9 +11,15 @@ import {
|
|
|
11
11
|
BlockControls,
|
|
12
12
|
Warning,
|
|
13
13
|
useBlockProps,
|
|
14
|
+
store as blockEditorStore,
|
|
14
15
|
} from '@wordpress/block-editor';
|
|
15
|
-
import { useEntityProp } from '@wordpress/core-data';
|
|
16
|
+
import { useEntityProp, store as coreStore } from '@wordpress/core-data';
|
|
16
17
|
import { __, sprintf } from '@wordpress/i18n';
|
|
18
|
+
import { useSelect } from '@wordpress/data';
|
|
19
|
+
/**
|
|
20
|
+
* Internal dependencies
|
|
21
|
+
*/
|
|
22
|
+
import CommentsForm from './form';
|
|
17
23
|
|
|
18
24
|
export default function PostCommentsFormEdit( {
|
|
19
25
|
attributes,
|
|
@@ -34,7 +40,49 @@ export default function PostCommentsFormEdit( {
|
|
|
34
40
|
} ),
|
|
35
41
|
} );
|
|
36
42
|
|
|
37
|
-
const
|
|
43
|
+
const isSiteEditor = postType === undefined || postId === undefined;
|
|
44
|
+
|
|
45
|
+
const { defaultCommentStatus } = useSelect(
|
|
46
|
+
( select ) =>
|
|
47
|
+
select( blockEditorStore ).getSettings()
|
|
48
|
+
.__experimentalDiscussionSettings
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const postTypeSupportsComments = useSelect( ( select ) =>
|
|
52
|
+
postType
|
|
53
|
+
? !! select( coreStore ).getPostType( postType )?.supports.comments
|
|
54
|
+
: false
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
let warning = false;
|
|
58
|
+
let showPlaceholder = true;
|
|
59
|
+
|
|
60
|
+
if ( ! isSiteEditor && 'open' !== commentStatus ) {
|
|
61
|
+
if ( 'closed' === commentStatus ) {
|
|
62
|
+
warning = sprintf(
|
|
63
|
+
/* translators: 1: Post type (i.e. "post", "page") */
|
|
64
|
+
__(
|
|
65
|
+
'Post Comments Form block: Comments on this %s are not allowed.'
|
|
66
|
+
),
|
|
67
|
+
postType
|
|
68
|
+
);
|
|
69
|
+
showPlaceholder = false;
|
|
70
|
+
} else if ( ! postTypeSupportsComments ) {
|
|
71
|
+
warning = sprintf(
|
|
72
|
+
/* translators: 1: Post type (i.e. "post", "page") */
|
|
73
|
+
__(
|
|
74
|
+
'Post Comments Form block: Comments for this post type (%s) are not enabled.'
|
|
75
|
+
),
|
|
76
|
+
postType
|
|
77
|
+
);
|
|
78
|
+
showPlaceholder = false;
|
|
79
|
+
} else if ( 'open' !== defaultCommentStatus ) {
|
|
80
|
+
warning = __(
|
|
81
|
+
'Post Comments Form block: Comments are not enabled.'
|
|
82
|
+
);
|
|
83
|
+
showPlaceholder = false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
38
86
|
|
|
39
87
|
return (
|
|
40
88
|
<>
|
|
@@ -47,28 +95,9 @@ export default function PostCommentsFormEdit( {
|
|
|
47
95
|
/>
|
|
48
96
|
</BlockControls>
|
|
49
97
|
<div { ...blockProps }>
|
|
50
|
-
{
|
|
51
|
-
<Warning>
|
|
52
|
-
{ __(
|
|
53
|
-
'Post Comments Form block: comments are not enabled for this post type.'
|
|
54
|
-
) }
|
|
55
|
-
</Warning>
|
|
56
|
-
) }
|
|
57
|
-
|
|
58
|
-
{ 'open' !== commentStatus && ! isInSiteEditor && (
|
|
59
|
-
<Warning>
|
|
60
|
-
{ sprintf(
|
|
61
|
-
/* translators: 1: Post type (i.e. "post", "page") */
|
|
62
|
-
__(
|
|
63
|
-
'Post Comments Form block: comments to this %s are not allowed.'
|
|
64
|
-
),
|
|
65
|
-
postType
|
|
66
|
-
) }
|
|
67
|
-
</Warning>
|
|
68
|
-
) }
|
|
98
|
+
{ warning && <Warning>{ warning }</Warning> }
|
|
69
99
|
|
|
70
|
-
{
|
|
71
|
-
__( 'Post Comments Form' ) }
|
|
100
|
+
{ showPlaceholder ? <CommentsForm /> : null }
|
|
72
101
|
</div>
|
|
73
102
|
</>
|
|
74
103
|
);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import {
|
|
6
|
+
__experimentalUseDisabled as useDisabled,
|
|
7
|
+
useInstanceId,
|
|
8
|
+
} from '@wordpress/compose';
|
|
9
|
+
|
|
10
|
+
const CommentsForm = () => {
|
|
11
|
+
const disabledFormRef = useDisabled();
|
|
12
|
+
const instanceId = useInstanceId( CommentsForm );
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className="comment-respond">
|
|
16
|
+
<h3 className="comment-reply-title">{ __( 'Leave a Reply' ) }</h3>
|
|
17
|
+
<form noValidate className="comment-form" ref={ disabledFormRef }>
|
|
18
|
+
<p>
|
|
19
|
+
<label htmlFor={ `comment-${ instanceId }` }>
|
|
20
|
+
{ __( 'Comment' ) }
|
|
21
|
+
</label>
|
|
22
|
+
<textarea
|
|
23
|
+
id={ `comment-${ instanceId }` }
|
|
24
|
+
name="comment"
|
|
25
|
+
cols="45"
|
|
26
|
+
rows="8"
|
|
27
|
+
/>
|
|
28
|
+
</p>
|
|
29
|
+
<p className="form-submit wp-block-button">
|
|
30
|
+
<input
|
|
31
|
+
name="submit"
|
|
32
|
+
type="submit"
|
|
33
|
+
className="submit wp-block-button__link"
|
|
34
|
+
label={ __( 'Post Comment' ) }
|
|
35
|
+
value={ __( 'Post Comment' ) }
|
|
36
|
+
/>
|
|
37
|
+
</p>
|
|
38
|
+
</form>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default CommentsForm;
|
|
@@ -18,17 +18,25 @@ function render_block_core_post_comments_form( $attributes, $content, $block ) {
|
|
|
18
18
|
return '';
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
if ( post_password_required( $block->context['postId'] ) ) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
21
25
|
$classes = 'comment-respond'; // See comment further below.
|
|
22
26
|
if ( isset( $attributes['textAlign'] ) ) {
|
|
23
|
-
$classes .= 'has-text-align-' . $attributes['textAlign'];
|
|
27
|
+
$classes .= ' has-text-align-' . $attributes['textAlign'];
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
|
|
27
31
|
|
|
32
|
+
add_filter( 'comment_form_defaults', 'post_comments_form_block_form_defaults' );
|
|
33
|
+
|
|
28
34
|
ob_start();
|
|
29
35
|
comment_form( array(), $block->context['postId'] );
|
|
30
36
|
$form = ob_get_clean();
|
|
31
37
|
|
|
38
|
+
remove_filter( 'comment_form_defaults', 'post_comments_form_block_form_defaults' );
|
|
39
|
+
|
|
32
40
|
// We use the outermost wrapping `<div />` returned by `comment_form()`
|
|
33
41
|
// which is identified by its default classname `comment-respond` to inject
|
|
34
42
|
// our wrapper attributes. This way, it is guaranteed that all styling applied
|
|
@@ -70,4 +78,3 @@ function post_comments_form_block_form_defaults( $fields ) {
|
|
|
70
78
|
|
|
71
79
|
return $fields;
|
|
72
80
|
}
|
|
73
|
-
add_filter( 'comment_form_defaults', 'post_comments_form_block_form_defaults' );
|
package/src/post-content/edit.js
CHANGED
|
@@ -85,7 +85,21 @@ function Placeholder() {
|
|
|
85
85
|
const blockProps = useBlockProps();
|
|
86
86
|
return (
|
|
87
87
|
<div { ...blockProps }>
|
|
88
|
-
<p>
|
|
88
|
+
<p>
|
|
89
|
+
{ __(
|
|
90
|
+
'This is the Post Content block, it will display all the blocks in any single post or page.'
|
|
91
|
+
) }
|
|
92
|
+
</p>
|
|
93
|
+
<p>
|
|
94
|
+
{ __(
|
|
95
|
+
'That might be a simple arrangement like consecutive paragraphs in a blog post, or a more elaborate composition that includes image galleries, videos, tables, columns, and any other block types.'
|
|
96
|
+
) }
|
|
97
|
+
</p>
|
|
98
|
+
<p>
|
|
99
|
+
{ __(
|
|
100
|
+
'If there are any Custom Post Types registered at your site, the Post Content block can display the contents of those entries as well.'
|
|
101
|
+
) }
|
|
102
|
+
</p>
|
|
89
103
|
</div>
|
|
90
104
|
);
|
|
91
105
|
}
|
package/src/post-excerpt/edit.js
CHANGED
|
@@ -57,7 +57,20 @@ export default function PostExcerptEditor( {
|
|
|
57
57
|
return document.body.textContent || document.body.innerText || '';
|
|
58
58
|
}, [ renderedExcerpt ] );
|
|
59
59
|
if ( ! postType || ! postId ) {
|
|
60
|
-
return
|
|
60
|
+
return (
|
|
61
|
+
<div { ...blockProps }>
|
|
62
|
+
<p>
|
|
63
|
+
{ __(
|
|
64
|
+
'This is the Post Excerpt block, it will display the excerpt from single posts.'
|
|
65
|
+
) }
|
|
66
|
+
</p>
|
|
67
|
+
<p>
|
|
68
|
+
{ __(
|
|
69
|
+
'If there are any Custom Post Types with support for excerpts, the Post Excerpt block can display the excerpts of those entries as well.'
|
|
70
|
+
) }
|
|
71
|
+
</p>
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
61
74
|
}
|
|
62
75
|
if ( isProtected && ! userCanEdit ) {
|
|
63
76
|
return (
|
package/src/post-terms/edit.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
BlockControls,
|
|
14
14
|
useBlockProps,
|
|
15
15
|
useBlockDisplayInformation,
|
|
16
|
+
RichText,
|
|
16
17
|
} from '@wordpress/block-editor';
|
|
17
18
|
import { Spinner, TextControl } from '@wordpress/components';
|
|
18
19
|
import { useSelect } from '@wordpress/data';
|
|
@@ -30,7 +31,7 @@ export default function PostTermsEdit( {
|
|
|
30
31
|
context,
|
|
31
32
|
setAttributes,
|
|
32
33
|
} ) {
|
|
33
|
-
const { term, textAlign, separator } = attributes;
|
|
34
|
+
const { term, textAlign, separator, prefix, suffix } = attributes;
|
|
34
35
|
const { postId, postType } = context;
|
|
35
36
|
|
|
36
37
|
const selectedTerm = useSelect(
|
|
@@ -83,6 +84,19 @@ export default function PostTermsEdit( {
|
|
|
83
84
|
</InspectorControls>
|
|
84
85
|
<div { ...blockProps }>
|
|
85
86
|
{ isLoading && <Spinner /> }
|
|
87
|
+
{ ! isLoading && hasPostTerms && (
|
|
88
|
+
<RichText
|
|
89
|
+
className="wp-block-post-terms__prefix"
|
|
90
|
+
multiline={ false }
|
|
91
|
+
aria-label={ __( 'Prefix' ) }
|
|
92
|
+
placeholder={ __( 'Prefix' ) + ' ' }
|
|
93
|
+
value={ prefix }
|
|
94
|
+
onChange={ ( value ) =>
|
|
95
|
+
setAttributes( { prefix: value } )
|
|
96
|
+
}
|
|
97
|
+
tagName="span"
|
|
98
|
+
/>
|
|
99
|
+
) }
|
|
86
100
|
{ ! isLoading &&
|
|
87
101
|
hasPostTerms &&
|
|
88
102
|
postTerms
|
|
@@ -108,6 +122,19 @@ export default function PostTermsEdit( {
|
|
|
108
122
|
! hasPostTerms &&
|
|
109
123
|
( selectedTerm?.labels?.no_terms ||
|
|
110
124
|
__( 'Term items not found.' ) ) }
|
|
125
|
+
{ ! isLoading && hasPostTerms && (
|
|
126
|
+
<RichText
|
|
127
|
+
className="wp-block-post-terms__suffix"
|
|
128
|
+
multiline={ false }
|
|
129
|
+
aria-label={ __( 'Suffix' ) }
|
|
130
|
+
placeholder={ ' ' + __( 'Suffix' ) }
|
|
131
|
+
value={ suffix }
|
|
132
|
+
onChange={ ( value ) =>
|
|
133
|
+
setAttributes( { suffix: value } )
|
|
134
|
+
}
|
|
135
|
+
tagName="span"
|
|
136
|
+
/>
|
|
137
|
+
) }
|
|
111
138
|
</div>
|
|
112
139
|
</>
|
|
113
140
|
);
|
package/src/post-terms/index.php
CHANGED
|
@@ -36,12 +36,22 @@ function render_block_core_post_terms( $attributes, $content, $block ) {
|
|
|
36
36
|
|
|
37
37
|
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
|
|
38
38
|
|
|
39
|
+
$prefix = "<div $wrapper_attributes>";
|
|
40
|
+
if ( isset( $attributes['prefix'] ) && $attributes['prefix'] ) {
|
|
41
|
+
$prefix .= '<span class="wp-block-post-terms__prefix">' . $attributes['prefix'] . '</span>';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
$suffix = '</div>';
|
|
45
|
+
if ( isset( $attributes['suffix'] ) && $attributes['suffix'] ) {
|
|
46
|
+
$suffix = '<span class="wp-block-post-terms__suffix">' . $attributes['suffix'] . '</span>' . $suffix;
|
|
47
|
+
}
|
|
48
|
+
|
|
39
49
|
return get_the_term_list(
|
|
40
50
|
$block->context['postId'],
|
|
41
51
|
$attributes['term'],
|
|
42
|
-
|
|
52
|
+
$prefix,
|
|
43
53
|
'<span class="wp-block-post-terms__separator">' . esc_html( $separator ) . '</span>',
|
|
44
|
-
|
|
54
|
+
$suffix
|
|
45
55
|
);
|
|
46
56
|
}
|
|
47
57
|
|
package/src/quote/block.json
CHANGED