From b40fc189e0e92a99286c93db241248d334e52cda Mon Sep 17 00:00:00 2001 From: rishishah-multidots Date: Fri, 25 Oct 2024 16:01:35 +0530 Subject: [PATCH 1/4] show comment form if there is no comment on any block and sidebar is open --- .../components/collab-sidebar/add-comment.js | 48 +++++++------------ .../src/components/collab-sidebar/index.js | 4 -- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/packages/editor/src/components/collab-sidebar/add-comment.js b/packages/editor/src/components/collab-sidebar/add-comment.js index 191bb23477f7bd..6e1661b507990e 100644 --- a/packages/editor/src/components/collab-sidebar/add-comment.js +++ b/packages/editor/src/components/collab-sidebar/add-comment.js @@ -21,39 +21,28 @@ 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. + * @param {Object} props - The component props. + * @param {Function} props.onSubmit - A callback function to be called when the user submits a comment. * @return {JSX.Element} The rendered comment input UI. */ -export function AddComment( { - onSubmit, - showCommentBoard, - setShowCommentBoard, -} ) { +export function AddComment( { onSubmit } ) { // 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 { defaultAvatar, clientId, blockCommentId, 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, + currentUser: userData, + }; + } + ); const userAvatar = currentUser && currentUser.avatar_urls && currentUser.avatar_urls[ 48 ] @@ -65,11 +54,10 @@ export function AddComment( { }, [ clientId ] ); const handleCancel = () => { - setShowCommentBoard( false ); setInputComment( '' ); }; - if ( ! showAddCommentBoard || ! clientId || undefined !== blockCommentId ) { + if ( ! clientId || undefined !== blockCommentId ) { return null; } diff --git a/packages/editor/src/components/collab-sidebar/index.js b/packages/editor/src/components/collab-sidebar/index.js index 482bf3d4081ed1..2d9fc3ae23a9e3 100644 --- a/packages/editor/src/components/collab-sidebar/index.js +++ b/packages/editor/src/components/collab-sidebar/index.js @@ -55,7 +55,6 @@ export default function CollabSidebar() { const { getEntityRecord } = resolveSelect( coreStore ); const { enableComplementaryArea } = useDispatch( interfaceStore ); const [ blockCommentID, setBlockCommentID ] = useState( null ); - const [ showCommentBoard, setShowCommentBoard ] = useState( false ); const { postId } = useSelect( ( select ) => { return { postId: select( editorStore ).getCurrentPostId(), @@ -126,7 +125,6 @@ export default function CollabSidebar() { }, [ threads ] ); const openCollabBoard = () => { - setShowCommentBoard( true ); enableComplementaryArea( 'core', 'edit-post/collab-sidebar' ); }; @@ -282,8 +280,6 @@ export default function CollabSidebar() { Date: Mon, 25 Nov 2024 11:47:01 +0530 Subject: [PATCH 2/4] resolve conflict with trunk --- packages/block-library/src/image/block.json | 9 +-------- packages/block-library/src/post-content/block.json | 1 + 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/block-library/src/image/block.json b/packages/block-library/src/image/block.json index 26835df9e856cd..16e31217476026 100644 --- a/packages/block-library/src/image/block.json +++ b/packages/block-library/src/image/block.json @@ -4,14 +4,7 @@ "name": "core/image", "title": "Image", "category": "media", - "usesContext": [ - "allowResize", - "imageCrop", - "fixedHeight", - "postId", - "postType", - "queryId" - ], + "usesContext": [ "allowResize", "imageCrop", "fixedHeight", "postId", "postType", "queryId" ], "description": "Insert an image to make a visual statement.", "keywords": [ "img", "photo", "picture" ], "textdomain": "default", diff --git a/packages/block-library/src/post-content/block.json b/packages/block-library/src/post-content/block.json index e5d455b97a8a3d..3af6679fe3a024 100644 --- a/packages/block-library/src/post-content/block.json +++ b/packages/block-library/src/post-content/block.json @@ -70,3 +70,4 @@ "style": "wp-block-post-content", "editorStyle": "wp-block-post-content-editor" } + From 4f7ff2c7ac2c7cabefd303d2a1079b875d01e2a8 Mon Sep 17 00:00:00 2001 From: rishishah-multidots Date: Mon, 25 Nov 2024 11:48:39 +0530 Subject: [PATCH 3/4] resolve conflict with trunk --- packages/block-library/src/post-content/block.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/block-library/src/post-content/block.json b/packages/block-library/src/post-content/block.json index 3af6679fe3a024..ed9c47154b2f8e 100644 --- a/packages/block-library/src/post-content/block.json +++ b/packages/block-library/src/post-content/block.json @@ -69,5 +69,4 @@ }, "style": "wp-block-post-content", "editorStyle": "wp-block-post-content-editor" -} - +} \ No newline at end of file From 8837ba7db2c077751e063505c3d9bbc35091ca21 Mon Sep 17 00:00:00 2001 From: rishishah-multidots Date: Tue, 3 Dec 2024 11:41:15 +0530 Subject: [PATCH 4/4] fix link error --- .../editor/src/components/collab-sidebar/index.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/editor/src/components/collab-sidebar/index.js b/packages/editor/src/components/collab-sidebar/index.js index 21f0c78c35a0ea..8fc8006989f94f 100644 --- a/packages/editor/src/components/collab-sidebar/index.js +++ b/packages/editor/src/components/collab-sidebar/index.js @@ -50,10 +50,7 @@ addFilter( modifyBlockCommentAttributes ); -function CollabSidebarContent( { - styles, - comments, -} ) { +function CollabSidebarContent( { styles, comments } ) { const { createNotice } = useDispatch( noticesStore ); const { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore ); const { getEntityRecord } = resolveSelect( coreStore ); @@ -194,9 +191,7 @@ function CollabSidebarContent( { return (
- + - +