Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Inline comment experimental flag #60622

Open
wants to merge 190 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
200bd36
Add Inline comment experimental flag
poojabhimani12 Apr 10, 2024
08d520f
Experimental block commenting
akashdhawade1991 May 14, 2024
4cddd7b
Fix comment display issue
akashdhawade1991 May 14, 2024
4fce70c
Fix comment button text issue
akashdhawade1991 May 14, 2024
ead6f64
Merge pull request #1 from akashdhawade2005/try/inline-block-commenting
poojabhimani12 May 15, 2024
5225f4d
Merge branch 'trunk' into try/inline-block-commenting
poojabhimani12 May 15, 2024
89930f1
Sync with trunk
akashdhawade1991 May 15, 2024
48ddd17
Merge pull request #2 from akashdhawade2005/try/inline-block-commenting
poojabhimani12 May 15, 2024
694c2ea
Update editor-settings.php
poojabhimani12 May 15, 2024
5be0043
Update experiments-page.php
poojabhimani12 May 15, 2024
682a21b
Fix: Broken README.md link for block library
akashdhawade1991 May 29, 2024
f4d866e
Block collab
akashdhawade1991 May 30, 2024
768d87d
Address pipeline issues
akashdhawade1991 Jun 3, 2024
d82ecc2
Address pipeline issues
akashdhawade1991 Jun 3, 2024
0cea02c
Merge pull request #3 from akashdhawade2005/try/inline-block-commenting
poojabhimani12 Jun 5, 2024
871c745
Added UI Design changes for Comment Popover section
juhibhatt19 Jun 6, 2024
82a01f4
Collab sidebar
akashdhawade1991 Jun 6, 2024
db64f73
Collab sidebar
akashdhawade1991 Jun 6, 2024
94c9d67
Fix sidebar comment icon issue
akashdhawade1991 Jun 6, 2024
ecd5c98
Merge pull request #6 from akashdhawade2005/try/inline-block-commenting
poojabhimani12 Jun 7, 2024
6d3eb6d
resolved conflicts
poojabhimani12 Jun 7, 2024
6132e5e
resolved conflicts
poojabhimani12 Jun 7, 2024
b9e182a
Resolved conflicts & added sidebar UI changes
juhibhatt19 Jun 7, 2024
618254a
Merge pull request #7 from juhibhatt19/try/inline-block-commenting
poojabhimani12 Jun 7, 2024
10c9ed0
Update comment functionality and reformating code
MD-sunilprajapati Jun 10, 2024
271895a
remove style import
MD-sunilprajapati Jun 10, 2024
f2b7114
Merge pull request #8 from MD-sunilprajapati/try/inline-block-commenting
poojabhimani12 Jun 10, 2024
5e0890c
revert the changes
MD-sunilprajapati Jun 10, 2024
031e8d5
resolved conflicts
poojabhimani12 Jun 10, 2024
6b0c3b3
Merge branch 'poojabhimani12:try/inline-block-commenting' into try/in…
MD-sunilprajapati Jun 10, 2024
d2d6215
Adjust spacing between icons
MD-sunilprajapati Jun 10, 2024
cbee86f
Merge pull request #9 from MD-sunilprajapati/try/inline-block-commenting
poojabhimani12 Jun 10, 2024
b36c2ab
resolved conflicts
poojabhimani12 Jun 10, 2024
b7b1ba4
Fix linting errors
MD-sunilprajapati Jun 11, 2024
6c0862d
Merge pull request #10 from MD-sunilprajapati/try/inline-block-commen…
poojabhimani12 Jun 12, 2024
77ee009
Add experimental condition
MD-sunilprajapati Jun 13, 2024
a8ea60e
Show sidebar on zero comments
MD-sunilprajapati Jun 13, 2024
ec302ff
Add package lock
MD-sunilprajapati Jun 13, 2024
f002607
Merge pull request #11 from MD-sunilprajapati/try/inline-block-commen…
poojabhimani12 Jun 13, 2024
fdc44a3
Update comment
MD-sunilprajapati Jun 14, 2024
bb2c0bd
Merge pull request #12 from MD-sunilprajapati/try/inline-block-commen…
poojabhimani12 Jun 14, 2024
e6ac0b4
Address feedbacks
MD-sunilprajapati Jun 18, 2024
9447911
Use useEntityProp
MD-sunilprajapati Jun 18, 2024
bf84cc4
Update sidebar content on new comment
MD-sunilprajapati Jun 18, 2024
57ed39a
Remove unneccessory changes
MD-sunilprajapati Jun 19, 2024
b9668fd
Relocate border styles for commented blocks
MD-sunilprajapati Jun 19, 2024
6628689
Merge pull request #13 from MD-sunilprajapati/try/inline-block-commen…
poojabhimani12 Jun 19, 2024
1d81922
set initial state instead of mount effect for block class
MD-sunilprajapati Jun 19, 2024
87fe4f9
Fix linting errors
MD-sunilprajapati Jun 19, 2024
139135d
Add dependencies
MD-sunilprajapati Jun 19, 2024
20f2bd3
Merge pull request #14 from MD-sunilprajapati/try/inline-block-commen…
poojabhimani12 Jun 19, 2024
2df0bdb
Merge branch 'WordPress:trunk' into try/inline-block-commenting
poojabhimani12 Jun 19, 2024
515a592
Update package lock
MD-sunilprajapati Jun 19, 2024
08fd837
Merge pull request #15 from MD-sunilprajapati/try/inline-block-commen…
poojabhimani12 Jun 20, 2024
251ae5f
Implement inline commenting
MD-sunilprajapati Jun 20, 2024
e747430
Update doc for collabboard component
MD-sunilprajapati Jun 20, 2024
b7a5bd7
Highlight inline text with comment
MD-sunilprajapati Jun 20, 2024
16d2186
Remove comments and console logs
MD-sunilprajapati Jul 24, 2024
877f090
Merge pull request #16 from MD-sunilprajapati/enabled-inline-commenting
poojabhimani12 Jul 25, 2024
1ce0191
made changes for collab.php file and removed block border color
rishishah-multidots Jul 29, 2024
1a677d8
Merge pull request #17 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Jul 29, 2024
d67d2b1
Resolved conflicts
poojabhimani12 Jul 29, 2024
e0cb8b5
Merge branch 'try/inline-block-commenting' of https://github.com/pooj…
poojabhimani12 Jul 29, 2024
9004004
Update editor-settings.php
poojabhimani12 Jul 29, 2024
d23a0a6
made changes for block comment feature
rishishah-multidots Aug 22, 2024
cf605d5
Merge branch 'try/inline-block-commenting' of github.com:rishishah-mu…
rishishah-multidots Aug 22, 2024
f115c3b
made changes for code_sniffer error on rest_api file
rishishah-multidots Aug 22, 2024
f748ad9
made changes for code_sniffer error on rest_api file
rishishah-multidots Aug 22, 2024
59e96c4
remove readme.md file from collab folder
rishishah-multidots Aug 22, 2024
18e5081
remove static email for comment author
rishishah-multidots Aug 22, 2024
c9f4964
Merge pull request #18 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Aug 22, 2024
1ed6d54
added edit/delete comment from sidebar feature
rishishah-multidots Aug 23, 2024
84733c5
resolve PHP coding standards errors
rishishah-multidots Aug 23, 2024
2d5d162
resolve PHP coding standards errors
rishishah-multidots Aug 23, 2024
e68cdcc
Merge pull request #19 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Aug 23, 2024
8042e22
Resolved Conflicts
poojabhimani12 Aug 28, 2024
ceb188c
Add idenrifier to collab sidebar
MD-sunilprajapati Aug 28, 2024
575361c
Relocate Add Comment button below in more action popover
MD-sunilprajapati Aug 29, 2024
8c45982
Update comment button action to focus new comment form in sidebar on …
MD-sunilprajapati Aug 29, 2024
a2345e8
Merge pull request #20 from MD-sunilprajapati/try/inline-block-commen…
poojabhimani12 Aug 29, 2024
2004c04
Update experimental field lable for commenting functionality
MD-sunilprajapati Aug 29, 2024
8ac8328
Revert format library changes
MD-sunilprajapati Aug 29, 2024
868c095
made changes as per Github
rishishah-multidots Aug 29, 2024
ab73559
Refactor collab sidebar
MD-sunilprajapati Aug 29, 2024
d5df8cc
Refactor collab sidebar
MD-sunilprajapati Aug 29, 2024
533c5d4
Remove unneccessory snapshot tests
MD-sunilprajapati Aug 29, 2024
c0a5dcd
Remove collab board component
MD-sunilprajapati Aug 29, 2024
56e475b
Fix linting errors
MD-sunilprajapati Aug 29, 2024
9de8c69
Merge pull request #21 from MD-sunilprajapati/collab-sidebar-update
poojabhimani12 Aug 29, 2024
4104869
made changes as per Github
rishishah-multidots Aug 29, 2024
b8b0292
made changes as per github feedback
rishishah-multidots Aug 29, 2024
6996e5f
Merge pull request #22 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Aug 29, 2024
0321430
comment board hide/show on Add comment and cancel button
rishishah-multidots Aug 29, 2024
3bf3c4c
Merge pull request #23 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Aug 29, 2024
c66fbcd
Revert format library changes
MD-sunilprajapati Aug 30, 2024
751d727
Sync with trunk and resolved conflicts
MD-sunilprajapati Aug 30, 2024
9a42d64
Merge pull request #24 from MD-sunilprajapati/address-feedbacks
poojabhimani12 Aug 30, 2024
68d5e1c
Merge branch 'WordPress:trunk' into try/inline-block-commenting
poojabhimani12 Aug 30, 2024
1f5a2c2
Focus comment board on comment icon click
MD-sunilprajapati Aug 30, 2024
6477102
Address feedback and create smaller component
MD-sunilprajapati Aug 30, 2024
66832a7
Create comment header component
MD-sunilprajapati Aug 30, 2024
5c70d90
Fix linting errors
MD-sunilprajapati Aug 30, 2024
cc28c6a
Remove logs
MD-sunilprajapati Aug 30, 2024
951d8b4
Fix linting errors
MD-sunilprajapati Aug 30, 2024
b0ad9d5
Merge pull request #25 from MD-sunilprajapati/refactor-collab-sidebar
poojabhimani12 Aug 30, 2024
a5e12e1
made changes as per PR feedback
rishishah-multidots Aug 30, 2024
cf59158
made changes as per PR feedback
rishishah-multidots Aug 30, 2024
6cfdb29
resolve style.scss conflict
rishishah-multidots Aug 30, 2024
465b438
Merge pull request #26 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Aug 30, 2024
c9d50d8
Refactor collab components
MD-sunilprajapati Sep 2, 2024
fd6f327
Implement comment reload on comment crud operation
MD-sunilprajapati Sep 2, 2024
15c85e0
remove string literals for data stores
MD-sunilprajapati Sep 2, 2024
c7be827
remove package json file changes
MD-sunilprajapati Sep 2, 2024
bd1a7ce
Add docs for components
MD-sunilprajapati Sep 2, 2024
19dfab8
Merge pull request #27 from MD-sunilprajapati/refactor-inline-commenting
poojabhimani12 Sep 2, 2024
48ee928
Merge branch 'WordPress:trunk' into try/inline-block-commenting
poojabhimani12 Sep 2, 2024
8fa3f85
remove revert function to show comments in sidebar and show comments …
rishishah-multidots Sep 2, 2024
5f0ae80
remove revert function to show comments in sidebar and show comments …
rishishah-multidots Sep 2, 2024
69d1878
Merge pull request #28 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Sep 2, 2024
d6e01f3
Remove string literels for gutenberg stores
MD-sunilprajapati Sep 2, 2024
668671b
Merge pull request #29 from MD-sunilprajapati/refactor-inline-comment…
poojabhimani12 Sep 2, 2024
ee6fe75
Sync with trunk and resolved conflicts
MD-sunilprajapati Sep 3, 2024
de2cd8f
Sync with trunk
MD-sunilprajapati Sep 3, 2024
8e6da19
Addressed feedback of collab sidebar component
MD-sunilprajapati Sep 3, 2024
90ba459
Merge pull request #30 from MD-sunilprajapati/collab-sidebar-feedbacks
poojabhimani12 Sep 3, 2024
e2fd75a
made changes for feedback
rishishah-multidots Sep 3, 2024
aad19d0
Merge pull request #31 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Sep 3, 2024
6f03c48
Refresh state on every new comment
MD-sunilprajapati Sep 3, 2024
2b057cc
Sync file with trunk
MD-sunilprajapati Sep 3, 2024
59caf1c
made changes for css property
rishishah-multidots Sep 3, 2024
efa41ac
Merge pull request #32 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Sep 3, 2024
4ee210d
code cleanup
MD-sunilprajapati Sep 3, 2024
38bea58
Merge pull request #33 from MD-sunilprajapati/collab-sidebar-cleanup
poojabhimani12 Sep 3, 2024
609cad6
Merge branch 'trunk' of gutenberg
MD-sunilprajapati Sep 4, 2024
8a54986
Update classes name and remove unwanted classes
minaldiwan Sep 4, 2024
2fd78b0
Merge pull request #35 from minaldiwan/try/inline-block-commenting
poojabhimani12 Sep 4, 2024
f236a42
made changes for translators and context
rishishah-multidots Sep 4, 2024
b3c879d
made changes for translators and context
rishishah-multidots Sep 4, 2024
bc308e9
Merge pull request #36 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Sep 4, 2024
11cf1f1
use entity record function instead api fetch
MD-sunilprajapati Sep 4, 2024
22c189a
Sync with origin and resolved coflicts
MD-sunilprajapati Sep 4, 2024
33cd398
small fix for translator string
rishishah-multidots Sep 4, 2024
211944c
Merge pull request #37 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Sep 4, 2024
a4abbec
Fix linting errors
MD-sunilprajapati Sep 4, 2024
5c99dcc
Merge branch 'try/inline-block-commenting' of gutenberg into collab-c…
MD-sunilprajapati Sep 4, 2024
50e8101
fix comment edit issue
MD-sunilprajapati Sep 5, 2024
ce7f7bc
Sync with origin and resolved coflicts
MD-sunilprajapati Sep 5, 2024
b0c5960
Fix linting errors
MD-sunilprajapati Sep 5, 2024
f768b4a
Merge pull request #34 from MD-sunilprajapati/collab-comment-cleanup
poojabhimani12 Sep 5, 2024
92870c4
pipeline error fixes
rishishah-multidots Sep 5, 2024
37fa922
pipeline error fixes and resolve conflicts
rishishah-multidots Sep 5, 2024
4d6841a
Merge pull request #38 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Sep 5, 2024
71f7a39
Fix linting errors
MD-sunilprajapati Sep 5, 2024
6f73a0b
Merge pull request #39 from MD-sunilprajapati/code-cleanup
poojabhimani12 Sep 5, 2024
edab788
Fix style linting issue
MD-sunilprajapati Sep 5, 2024
6e528a1
Fix useMemo dependacy
MD-sunilprajapati Sep 5, 2024
b129367
Merge pull request #40 from MD-sunilprajapati/fix-linting-errors
poojabhimani12 Sep 5, 2024
8d17f22
Remove styling for input and textarea box as per core team feedback
minaldiwan Sep 5, 2024
fd4c045
Merge pull request #41 from minaldiwan/try/inline-block-commenting
poojabhimani12 Sep 5, 2024
4d3eeb1
added error message for add comment on draft mode or duplicate comment
rishishah-multidots Sep 5, 2024
f06340a
Merge branch 'try/inline-block-commenting' of github.com:rishishah-mu…
rishishah-multidots Sep 5, 2024
6b8027a
resolve eslint error and update blockEditorStore feature
rishishah-multidots Sep 5, 2024
06c8526
revert package files as per trunk
rishishah-multidots Sep 5, 2024
e1d4396
revert package files as per main branch
rishishah-multidots Sep 5, 2024
c78f981
Merge pull request #42 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Sep 5, 2024
da72b79
Addressed feedback
MD-sunilprajapati Sep 6, 2024
d7bca6e
cleanup code
MD-sunilprajapati Sep 6, 2024
68d203e
Update context for edit button
MD-sunilprajapati Sep 6, 2024
b296d2d
Merge pull request #43 from MD-sunilprajapati/address-feedback
poojabhimani12 Sep 6, 2024
bddceeb
feedback changes
rishishah-multidots Sep 6, 2024
c5094a0
Merge branch 'try/inline-block-commenting' of github.com:rishishah-mu…
rishishah-multidots Sep 6, 2024
a23241a
feedback changes for comment rest API
rishishah-multidots Sep 6, 2024
9548565
Merge pull request #44 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Sep 6, 2024
06e840f
Merge branch 'WordPress:trunk' into try/inline-block-commenting
poojabhimani12 Sep 6, 2024
3883a11
comment rest api function in condition
rishishah-multidots Sep 6, 2024
334daf2
Merge pull request #45 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Sep 6, 2024
b028876
Merge branch 'WordPress:trunk' into try/inline-block-commenting
poojabhimani12 Sep 9, 2024
cd63f6a
Fix reply comment issue
MD-sunilprajapati Sep 10, 2024
9b12661
Merge pull request #50 from MD-sunilprajapati/fix-reply-comment-issue
poojabhimani12 Sep 10, 2024
f287eff
Remove comment icon
MD-sunilprajapati Sep 10, 2024
16ebd4c
Merge pull request #51 from MD-sunilprajapati/remove-icon
poojabhimani12 Sep 10, 2024
7aa5508
update comment icon code for menu and toolbar group
rishishah-multidots Sep 13, 2024
e55109f
resolve eslint errors
rishishah-multidots Sep 13, 2024
f66d825
revert package-lock file
rishishah-multidots Sep 13, 2024
7ff9a79
Merge pull request #59 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Sep 13, 2024
d01c693
resolve trunk conflicts
rishishah-multidots Sep 16, 2024
2caf2d1
Merge pull request #60 from rishishah-multidots/sync-with-trunk
poojabhimani12 Sep 16, 2024
6bda66d
sync rest-api file with api PR
rishishah-multidots Sep 24, 2024
64b1b31
sync rest-api file with api PR
rishishah-multidots Sep 24, 2024
31ea3b5
Merge pull request #61 from rishishah-multidots/try/inline-block-comm…
poojabhimani12 Sep 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions lib/compat/wordpress-6.7/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,62 @@ function gutenberg_override_default_rest_server() {
return 'Gutenberg_REST_Server';
}
add_filter( 'wp_rest_server_class', 'gutenberg_override_default_rest_server', 1 );

/**
* Updates the comment type in the REST API for WordPress version 6.7.
*
* This function is used as a filter callback for the 'rest_pre_insert_comment' hook.
* It checks if the 'comment_type' parameter is set to 'block_comment' in the REST API request,
* and if so, updates the 'comment_type' and 'comment_approved' properties of the prepared comment.
*
* @param array $prepared_comment The prepared comment data.
* @param WP_REST_Request $request The REST API request object.
* @return array The updated prepared comment data.
*/
if ( ! function_exists( 'update_comment_type_in_rest_api_6_7' ) && gutenberg_is_experiment_enabled( 'gutenberg-block-comment' ) ) {
function update_comment_type_in_rest_api_6_7( $prepared_comment, $request ) {
if ( ! empty( $request['comment_type'] ) && 'block_comment' === $request['comment_type'] ) {
$prepared_comment['comment_type'] = $request['comment_type'];
$prepared_comment['comment_approved'] = $request['comment_approved'];
}

return $prepared_comment;
}
add_filter( 'rest_pre_insert_comment', 'update_comment_type_in_rest_api_6_7', 10, 2 );
}

/**
* Updates the comment type for avatars in the WordPress REST API.
*
* This function adds the 'block_comment' type to the list of comment types
* for which avatars should be retrieved in the WordPress REST API.
*
* @param array $comment_type The array of comment types.
* @return array The updated array of comment types.
*/
if ( ! function_exists( 'update_get_avatar_comment_type' ) && gutenberg_is_experiment_enabled( 'gutenberg-block-comment' ) ) {
function update_get_avatar_comment_type( $comment_type ) {
$comment_type[] = 'block_comment';
return $comment_type;
}
add_filter( 'get_avatar_comment_types', 'update_get_avatar_comment_type', 10, 1 );
}

/**
* Updates the comment type filter dropdown options.
*
* This function is only defined if the 'gutenberg-block-comment' experiment is enabled and the 'update_comment_type_filter_dropdown' function does not already exist.
* It returns an array of comment type options for the comment type filter dropdown in the admin area.
*
* @return array An associative array of comment type options.
* The keys are the comment type slugs and the values are the translated names of the comment types.
*/
if ( ! function_exists( 'update_comment_type_filter_dropdown' ) && gutenberg_is_experiment_enabled( 'gutenberg-block-comment' ) ) {
function update_comment_type_filter_dropdown() {
return array(
'comment' => __( 'Comments' ),
'block_comment' => __( 'Block Comments' ),
);
}
add_filter( 'admin_comment_types_dropdown', 'update_comment_type_filter_dropdown' );
}
3 changes: 3 additions & 0 deletions lib/experimental/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ function gutenberg_enable_experiments() {
if ( gutenberg_is_experiment_enabled( 'gutenberg-full-page-client-side-navigation' ) ) {
wp_add_inline_script( 'wp-block-library', 'window.__experimentalFullPageClientSideNavigation = true', 'before' );
}
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-block-comment', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableBlockComment = true', 'before' );
}
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-quick-edit-dataviews', $gutenberg_experiments ) ) {
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalQuickEditDataViews = true', 'before' );
}
Expand Down
12 changes: 12 additions & 0 deletions lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@ function gutenberg_initialize_experiments_settings() {
)
);

add_settings_field(
'gutenberg-block-comment',
__( 'Block Comments', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Enable multi-user commenting on blocks', 'gutenberg' ),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should say something about being internal or for collaborators.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We’ve made this update based on the feedback provided here: #60622 (comment).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to defer to Matías if he has suggestions. Perhaps: "Enable collaborative commenting on blocks."?

'id' => 'gutenberg-block-comment',
)
);

add_settings_field(
'gutenberg-media-processing',
__( 'Client-side media processing', 'gutenberg' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { pipe, useCopyToClipboard } from '@wordpress/compose';
* Internal dependencies
*/
import BlockActions from '../block-actions';
import __unstableCommentIconFill from '../collab/block-comment-icon-slot';
import BlockHTMLConvertButton from './block-html-convert-button';
import __unstableBlockSettingsMenuFirstItem from './block-settings-menu-first-item';
import BlockSettingsMenuControls from '../block-settings-menu-controls';
Expand Down Expand Up @@ -278,6 +279,11 @@ export function BlockSettingsDropdown( {
</MenuItem>
</>
) }

<__unstableCommentIconFill.Slot
fillProps={ { onClose } }
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need another slot, we already have BlockSettingsMenuControls or __unstableBlockSettingsMenuFirstItem in this menu already. Can we use one of these?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on feedback, we've added a new slot to display the comment icon below the "Add after" option. If we use the __unstableBlockSettingsMenuFirstItem slot, the comment icon will instead appear at the top of the menu group.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, how important the position is. Can it be at the top or at the end of the menu instead ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can position it at the top, as shown here. We can also confirm with jasmussen to ensure he's okay with this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


</MenuGroup>
{ canCopyStyles && ! isContentOnly && (
<MenuGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import { ToolbarGroup, ToolbarItem } from '@wordpress/components';
* Internal dependencies
*/
import BlockSettingsDropdown from './block-settings-dropdown';
import __unstableCommentIconToolbarFill from '../collab/block-comment-icon-toolbar-slot';

export function BlockSettingsMenu( { clientIds, ...props } ) {
return (
<ToolbarGroup>

<__unstableCommentIconToolbarFill.Slot />

<ToolbarItem>
{ ( toggleProps ) => (
<BlockSettingsDropdown
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* WordPress dependencies
*/
import { createSlotFill } from '@wordpress/components';

const { Fill: __unstableCommentIconFill, Slot } = createSlotFill(
'__unstableCommentIconFill'
);

__unstableCommentIconFill.Slot = Slot;

export default __unstableCommentIconFill;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* WordPress dependencies
*/
import { createSlotFill } from '@wordpress/components';

const { Fill: __unstableCommentIconToolbarFill, Slot } = createSlotFill(
'__unstableCommentIconToolbarFill'
);

__unstableCommentIconToolbarFill.Slot = Slot;

export default __unstableCommentIconToolbarFill;
3 changes: 3 additions & 0 deletions packages/block-editor/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ export {
*/

export { default as __unstableBlockSettingsMenuFirstItem } from './block-settings-menu/block-settings-menu-first-item';
export { default as __unstableCommentIconFill } from './collab/block-comment-icon-slot';
export { default as __unstableCommentIconToolbarFill } from './collab/block-comment-icon-toolbar-slot';

export { default as __unstableBlockToolbarLastItem } from './block-toolbar/block-toolbar-last-item';
export { default as __unstableBlockNameContext } from './block-toolbar/block-name-context';
export { default as __unstableInserterMenuExtension } from './inserter-menu-extension';
Expand Down
1 change: 1 addition & 0 deletions packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@babel/runtime": "^7.16.0",
"@wordpress/a11y": "file:../a11y",
"@wordpress/api-fetch": "file:../api-fetch",
"@wordpress/autop": "^4.7.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? This is a sort of legacy package that should be avoided. I don't understand why it's needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on feedback, we have added this package.

"@wordpress/blob": "file:../blob",
"@wordpress/block-editor": "file:../block-editor",
"@wordpress/blocks": "file:../blocks",
Expand Down
120 changes: 120 additions & 0 deletions packages/editor/src/components/collab-sidebar/add-comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/**
* WordPress dependencies
*/
import { __, _x } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { useState, useEffect } from '@wordpress/element';
import {
__experimentalHStack as HStack,
__experimentalVStack as VStack,
Button,
TextControl,
} from '@wordpress/components';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { store as coreStore } from '@wordpress/core-data';

/**
* Internal dependencies
*/
import { sanitizeCommentString } from './utils';

/**
* Renders the UI for adding a comment in the Gutenberg editor's collaboration sidebar.
*
* @param {Object} props - The component props.
* @param {Function} props.onSubmit - A callback function to be called when the user submits a comment.
* @param {boolean} props.showCommentBoard - The function to edit the comment.
* @param {Function} props.setShowCommentBoard - The function to delete the comment.
* @return {JSX.Element} The rendered comment input UI.
*/
export function AddComment( {
onSubmit,
showCommentBoard,
setShowCommentBoard,
} ) {
// State to manage the comment thread.
const [ inputComment, setInputComment ] = useState( '' );

const {
defaultAvatar,
clientId,
blockCommentId,
showAddCommentBoard,
currentUser,
} = useSelect( ( select ) => {
const { getSettings } = select( blockEditorStore );
const { __experimentalDiscussionSettings } = getSettings();
const selectedBlock = select( blockEditorStore ).getSelectedBlock();
const userData = select( coreStore ).getCurrentUser();
return {
defaultAvatar: __experimentalDiscussionSettings?.avatarURL,
clientId: selectedBlock?.clientId,
blockCommentId: selectedBlock?.attributes?.blockCommentId,
showAddCommentBoard: showCommentBoard,
currentUser: userData,
};
} );

const userAvatar = currentUser?.avatar_urls[ 48 ] ?? defaultAvatar;

useEffect( () => {
setInputComment( '' );
}, [ clientId ] );

const handleCancel = () => {
setShowCommentBoard( false );
setInputComment( '' );
};

if ( ! showAddCommentBoard || ! clientId || 0 !== blockCommentId ) {
return null;
}

return (
<VStack
spacing="3"
className="editor-collab-sidebar-panel__thread editor-collab-sidebar-panel__active-thread"
>
<HStack alignment="left" spacing="3">
<img
src={ userAvatar }
// translators: alt text for user avatar image
alt={ __( 'User Avatar' ) }
className="editor-collab-sidebar-panel__user-avatar"
width={ 32 }
height={ 32 }
/>
<span className="editor-collab-sidebar-panel__user-name">
{ currentUser?.name ?? '' }
</span>
</HStack>
<TextControl
__next40pxDefaultSize
__nextHasNoMarginBottom
value={ inputComment }
onChange={ setInputComment }
placeholder={ _x( 'Comment', 'noun' ) }
/>
<HStack alignment="right" spacing="3">
<Button
__next40pxDefaultSize
variant="tertiary"
text={ _x( 'Cancel', 'Cancel comment button' ) }
onClick={ handleCancel }
size="compact"
/>
<Button
__next40pxDefaultSize
accessibleWhenDisabled
variant="primary"
text={ _x( 'Comment', 'Add comment button' ) }
disabled={
0 === sanitizeCommentString( inputComment ).length
}
onClick={ () => onSubmit( inputComment ) }
size="compact"
/>
</HStack>
</VStack>
);
}
23 changes: 23 additions & 0 deletions packages/editor/src/components/collab-sidebar/commentButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* WordPress dependencies
*/
import { MenuItem } from '@wordpress/components';
import { _x } from '@wordpress/i18n';
import { comment as commentIcon } from '@wordpress/icons';
import { __unstableCommentIconFill as CommentIconFill } from '@wordpress/block-editor';

const AddCommentButton = ( { onClick } ) => {
return (
<CommentIconFill>
<MenuItem
icon={ commentIcon }
onClick={ onClick }
aria-haspopup="dialog"
>
{ _x( 'Comment', 'Add comment button' ) }
</MenuItem>
</CommentIconFill>
);
};

export default AddCommentButton;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* WordPress dependencies
*/
import { ToolbarButton } from '@wordpress/components';
import { _x } from '@wordpress/i18n';
import { comment as commentIcon } from '@wordpress/icons';
import { __unstableCommentIconToolbarFill as CommentIconToolbarFill } from '@wordpress/block-editor';

const AddCommentToolbarButton = ( { onClick } ) => {
return (
<CommentIconToolbarFill>
<ToolbarButton
accessibleWhenDisabled
icon={ commentIcon }
label={ _x( 'Comment', 'Open comment button' ) }
onClick={ onClick }
/>
</CommentIconToolbarFill>
);
};

export default AddCommentToolbarButton;
Loading