diff --git a/lib/compat/wordpress-6.6/rest-api.php b/lib/compat/wordpress-6.6/rest-api.php index d54f2e21fc73bc..bcd404039b2f7d 100644 --- a/lib/compat/wordpress-6.6/rest-api.php +++ b/lib/compat/wordpress-6.6/rest-api.php @@ -191,8 +191,8 @@ function gutenberg_block_editor_preload_paths_6_6( $paths, $context ) { * @param WP_REST_Request $request The request object. * @return WP_REST_Response The updated response object. */ -if ( ! function_exists( 'update_comment_meta_from_rest_request' ) ) { - function update_comment_meta_from_rest_request( $response, $comment, $request ) { +if ( ! function_exists( 'update_comment_meta_from_rest_request_6_6' ) ) { + function update_comment_meta_from_rest_request_6_6( $response, $comment, $request ) { if ( isset( $request['comment_type'] ) && ! empty( $request['comment_type'] ) ) { $comment_data = array( @@ -204,9 +204,8 @@ function update_comment_meta_from_rest_request( $response, $comment, $request ) wp_update_comment( $comment_data ); } - $author = get_user_by( 'login', $response->data['author_name'] ); - if ( $author ) { - $avatar_url = get_avatar_url( $author->ID ); + if ( $response->data['author'] ) { + $avatar_url = get_avatar_url( $response->data['author'] ); $response->data['author_avatar_urls'] = array( 'default' => $avatar_url, '48' => add_query_arg( 's', 48, $avatar_url ), @@ -214,15 +213,7 @@ function update_comment_meta_from_rest_request( $response, $comment, $request ) ); } - $comment_id = $comment->comment_ID; - $meta_key = 'block_comment'; - $meta_value = get_comment_meta( $comment_id, $meta_key, true ); - - if ( ! empty( $meta_value ) ) { - $response->data['meta'] = $meta_value; - } - return $response; } } -add_filter( 'rest_prepare_comment', 'update_comment_meta_from_rest_request', 10, 3 ); +add_filter( 'rest_prepare_comment', 'update_comment_meta_from_rest_request_6_6', 10, 3 ); diff --git a/lib/compat/wordpress-6.7/rest-api.php b/lib/compat/wordpress-6.7/rest-api.php index c5e2927198da0c..1fa4ac8cb04085 100644 --- a/lib/compat/wordpress-6.7/rest-api.php +++ b/lib/compat/wordpress-6.7/rest-api.php @@ -114,3 +114,46 @@ function gutenberg_override_default_rest_server() { return 'Gutenberg_REST_Server'; } add_filter( 'wp_rest_server_class', 'gutenberg_override_default_rest_server', 1 ); + +/** + * Updates comment metadata from a REST API request. + * + * This function is hooked to the `rest_prepare_comment` filter and is responsible for updating the comment metadata based on the data provided in the REST API request. + * + * It performs the following tasks: + * - Updates the `block_comment` metadata for the comment based on the `meta` field in the request. + * - Updates the `comment_type` and `comment_approved` fields for the comment based on the corresponding fields in the request. + * - Retrieves the author's avatar URLs and adds them to the response data. + * - Retrieves the `block_comment` metadata for the comment and adds it to the response data. + * + * @param WP_REST_Response $response The response object. + * @param WP_Comment $comment The comment object. + * @param WP_REST_Request $request The request object. + * @return WP_REST_Response The updated response object. + */ +if ( ! function_exists( 'update_comment_meta_from_rest_request_6_7' ) ) { + function update_comment_meta_from_rest_request_6_7( $response, $comment, $request ) { + + if ( isset( $request['comment_type'] ) && ! empty( $request['comment_type'] ) ) { + $comment_data = array( + 'comment_ID' => $comment->comment_ID, + 'comment_type' => $request['comment_type'], + 'comment_approved' => isset( $request['comment_approved'] ) ? $request['comment_approved'] : 0, + ); + + wp_update_comment( $comment_data ); + } + + if ( $response->data['author'] ) { + $avatar_url = get_avatar_url( $response->data['author'] ); + $response->data['author_avatar_urls'] = array( + 'default' => $avatar_url, + '48' => add_query_arg( 's', 48, $avatar_url ), + '96' => add_query_arg( 's', 96, $avatar_url ), + ); + } + + return $response; + } +} +add_filter( 'rest_prepare_comment', 'update_comment_meta_from_rest_request_6_7', 10, 3 ); diff --git a/package-lock.json b/package-lock.json index b910ce57d5e44c..30ffaa01be8526 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53655,10 +53655,7 @@ "@wordpress/block-editor": "file:../block-editor", "@wordpress/components": "file:../components", "@wordpress/compose": "file:../compose", - "@wordpress/core-data": "file:../core-data", "@wordpress/data": "file:../data", - "@wordpress/date": "file:../date", - "@wordpress/editor": "file:../editor", "@wordpress/element": "file:../element", "@wordpress/html-entities": "file:../html-entities", "@wordpress/i18n": "file:../i18n", @@ -68213,10 +68210,7 @@ "@wordpress/block-editor": "file:../block-editor", "@wordpress/components": "file:../components", "@wordpress/compose": "file:../compose", - "@wordpress/core-data": "file:../core-data", "@wordpress/data": "file:../data", - "@wordpress/date": "file:../date", - "@wordpress/editor": "file:../editor", "@wordpress/element": "file:../element", "@wordpress/html-entities": "file:../html-entities", "@wordpress/i18n": "file:../i18n", diff --git a/packages/editor/src/components/collab-sidebar/comments.js b/packages/editor/src/components/collab-sidebar/comments.js index ff9025d2ad28cf..0aec583689a533 100644 --- a/packages/editor/src/components/collab-sidebar/comments.js +++ b/packages/editor/src/components/collab-sidebar/comments.js @@ -780,6 +780,7 @@ function CommentHeader( { thread, onResolve, onEdit, onDelete, onReply } ) { diff --git a/packages/editor/src/components/collab-sidebar/style.scss b/packages/editor/src/components/collab-sidebar/style.scss index 928b3ba5adfc68..03c6f12701feea 100644 --- a/packages/editor/src/components/collab-sidebar/style.scss +++ b/packages/editor/src/components/collab-sidebar/style.scss @@ -43,7 +43,7 @@ width: 100%; } - .components-textarea-control__input { + textarea { border: 1px solid $gray-300; border-radius: 8px; padding: 10px 15px; @@ -89,18 +89,6 @@ flex-shrink: 0; } - &__userstatus { - button { - font-size: 12px; - font-weight: 400; - line-height: 16px; - padding: 0; - height: auto; - box-shadow: none; - outline: none; - } - } - &__useroverlay { background-color: rgba(0, 0, 0, 0.7); width: 100%; @@ -125,33 +113,26 @@ } } - &__resolvedIcon { - fill: #008000; - border-radius: 50%; - width: 18px; - height: 18px; - border: 1px solid #008000; - margin-right: 2px; - margin-top: 5px; - } - &__commentUpdate { margin-left: auto; - .components-button { - &.has-icon:not(.has-text) { - min-width: 24px; - padding: 0; - width: 24px; - height: 24px; - flex-shrink: 0; + button { + &.is-compact { + &.has-icon:not(.has-text) { + min-width: 24px; + padding: 0; + width: 24px; + height: 24px; + flex-shrink: 0; + } } } + } + &__commentDropdown { + flex-shrink: 0; - .components-dropdown { - flex-shrink: 0; - - .components-button { + button { + &.has-icon { min-width: 24px; padding: 0; width: 24px; @@ -160,103 +141,8 @@ } } - &__resolvedText { - font-style: italic; - font-weight: 500 !important; - color: #808080 !important; - margin-top: 5px !important; - } } .is-collab-block-selected { background-color: color-mix(in srgb, currentColor 5%, #182f97 20%); } - -.block-editor-format-toolbar__comment-board { - z-index: 1000001; - - .components-modal__frame { - max-width: 380px; - min-width: auto; - width: 90vw; - } - - .components-modal__content { - margin-top: 0; - padding: 32px 32px; - - .components-modal__header { - display: none; - } - } - - .comment-board__userIcon { - width: 35px; - height: 35px; - max-width: 100%; - border-radius: 50%; - } - - .comment-board__comment { - border-bottom: 1px solid $gray-300; - } - - &__resolved { - align-self: end; - } - - .comment-board__actions { - width: auto; - } - - .comment-board__userName { - font-size: 16px; - text-transform: capitalize; - } - - .comment-board__commentText { - font-size: 14px; - margin-top: 5px; - } - - .comment-board__dateTime { - font-size: 12px; - } - - .block-editor-format-toolbar__comment-input { - .components-text-control__input { - border: 1px solid #ccc; - height: 40px; - - &::placeholder { - font-style: italic; - } - - &:focus { - border-color: #2271b1; - } - } - } - - .block-editor-format-toolbar__comment-board__resolved { - min-width: auto; - - * { - min-width: auto; - } - - span.components-checkbox-control__input-container { - display: none; - - & + label { - text-decoration: underline; - cursor: pointer; - color: rgb(0, 124, 186); - } - } - } - - .block-editor-format-toolbar__comment-board__edit { - margin-right: -8px; - } -}